Improve python3 detection
Improve python3 detection

--- a/resources/lib/api.py
+++ b/resources/lib/api.py
@@ -163,10 +163,8 @@
     """Get cookie file path
     """
     profile_path = xbmc.translatePath(args._addon.getAddonInfo("profile"))
-    try:
-        # python2
+    if args.PY2:
         return os.path.join(profile_path.decode("utf-8"), u"cookies.lwp")
-    except AttributeError:
-        # python3
+    else:
         return os.path.join(profile_path, "cookies.lwp")
 

--- a/resources/lib/cmdargs.py
+++ b/resources/lib/cmdargs.py
@@ -42,6 +42,7 @@
         """Initialize arguments object
         Hold also references to the addon which can't be kept at module level.
         """
+        self.PY2        = sys.version_info[0] == 2 #: True for Python 2
         self._addon     = sys.modules["__main__"]._addon
         self._addonname = sys.modules["__main__"]._plugin
         self._addonid   = sys.modules["__main__"]._plugId

--- a/resources/lib/view.py
+++ b/resources/lib/view.py
@@ -83,15 +83,14 @@
                                 totalItems = total_items)
 
 
-def quote_value(value):
-    """Proper quote on both python2 and python3 (feature detection)
-       Remove after python3 migration
+def quote_value(value, PY2):
+    """Quote value depending on python
     """
-    try:
+    if PY2:
         if not isinstance(value, basestring):
             value = str(value)
         return quote_plus(value.encode("utf-8") if isinstance(value, unicode) else value)
-    except NameError:
+    else:
         if not isinstance(value, str):
             value = str(value)
         return quote_plus(value)
@@ -104,12 +103,12 @@
     # step 1 copy new information from info
     for key, value in list(info.items()):
         if value:
-            s = s + "&" + key + "=" + quote_value(value)
+            s = s + "&" + key + "=" + quote_value(value, args.PY2)
 
     # step 2 copy old information from args, but don't append twice
     for key, value in list(args.__dict__.items()):
         if value and key in types and not "&" + str(key) + "=" in s:
-            s = s + "&" + key + "=" + quote_value(value)
+            s = s + "&" + key + "=" + quote_value(value, args.PY2)
 
     return sys.argv[0] + "?" + s[1:]