From: Alexis Murzeau <amubtdx@outlook.fr>
Date: Sun, 23 Apr 2017 15:54:58 +0200
Subject: Support older pycountry

Debian has a older pycountry and it does not have the languages.lookup method.
Use languages.get with alpha2 instead.

Forwarded: not-needed
Author: Alexis Murzeau <amubtdx@outlook.fr>
---
 src/streamlink/utils/l10n.py | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/src/streamlink/utils/l10n.py b/src/streamlink/utils/l10n.py
index 0164c7c..49456d1 100644
--- a/src/streamlink/utils/l10n.py
+++ b/src/streamlink/utils/l10n.py
@@ -10,6 +10,14 @@ try:
 except ImportError:  # pragma: no cover
     from pycountry import languages, countries
 
+    def lookup(db, value):
+        for key in db.indices:
+            try:
+                return db.indices[key][value]
+            except LookupError:
+                pass
+        raise LookupError('Could not find a record for %r' % value)
+
     PYCOUNTRY = True
 
 DEFAULT_LANGUAGE = "en"
@@ -29,8 +37,8 @@ class Country(object):
     def get(cls, country):
         try:
             if PYCOUNTRY:
-                c = countries.lookup(country)
-                return Country(c.alpha_2, c.alpha_3, c.numeric, c.name, getattr(c, "official_name", c.name))
+                c = lookup(countries, country)
+                return Country(c.alpha2, c.alpha3, c.numeric, c.name, getattr(c, "official_name", c.name))
             else:
                 c = countries.get(country)
                 return Country(c.alpha2, c.alpha3, c.numeric, c.name, c.apolitical_name)
@@ -67,8 +75,8 @@ class Language(object):
     def get(cls, language):
         try:
             if PYCOUNTRY:
-                c = languages.lookup(language)
-                return Language(c.alpha_2, c.alpha_3, c.name, getattr(c, "bibliographic", None))
+                c = lookup(languages, language)
+                return Language(c.alpha2, c.terminology, c.name, getattr(c, "bibliographic", None))
             else:
                 l = None
                 if len(language) == 2:
