From 06c85ccc699d4f7b825406ba68e1c9900d315414 Mon Sep 17 00:00:00 2001
From: A69Tor <algorath69tor@gmail.com>
Date: Fri, 6 May 2016 16:04:39 -0400
Subject: [PATCH 1/9] Update strings.xml

Add Force Transcode Hi10P
---
 resources/language/English/strings.xml | 1 +
 1 file changed, 1 insertion(+)

diff --git a/resources/language/English/strings.xml b/resources/language/English/strings.xml
index 3a8d7ba4..1a145adc 100644
--- a/resources/language/English/strings.xml
+++ b/resources/language/English/strings.xml
@@ -299,6 +299,7 @@
     <string id="30534">Server messages</string>
     <string id="30535">Generate a new device Id</string>
     <string id="30536">Sync when screensaver is deactivated</string>
+    <string id="30537">Force Transcode Hi10P</string>    
 
     <!-- service add-on -->
     <string id="33000">Welcome</string>

From 27f877164228f331e351f64df10a36b782bc5d1f Mon Sep 17 00:00:00 2001
From: A69Tor <algorath69tor@gmail.com>
Date: Fri, 6 May 2016 16:05:17 -0400
Subject: [PATCH 2/9] Update settings.xml

Add Force Transcode Hi10P setting
---
 resources/settings.xml | 1 +
 1 file changed, 1 insertion(+)

diff --git a/resources/settings.xml b/resources/settings.xml
index 24458165..6deb4810 100644
--- a/resources/settings.xml
+++ b/resources/settings.xml
@@ -55,6 +55,7 @@
 	    <setting id="playFromStream" type="bool" label="30002" default="false" />
 	    <setting id="videoBitrate" type="enum" label="30160" values="664 Kbps SD|996 Kbps HD|1.3 Mbps HD|2.0 Mbps HD|3.2 Mbps HD|4.7 Mbps HD|6.2 Mbps HD|7.7 Mbps HD|9.2 Mbps HD|10.7 Mbps HD|12.2 Mbps HD|13.7 Mbps HD|15.2 Mbps HD|16.7 Mbps HD|18.2 Mbps HD|20.0 Mbps HD|40.0 Mbps HD|100.0 Mbps HD [default]|1000.0 Mbps HD" visible="true" default="17" subsetting="true" />
 	    <setting id="transcodeH265" type="enum" label="30522" default="0" values="Disabled|480p(and higher)|720p(and higher)|1080p" />
+	    <setting id="transcodeHi10P" type="bool" label="30537" visible="eq(-1,true)" default="false" subsetting="true" />	    
 	    <setting id="markPlayed" type="number" visible="false" default="90" />
 	    <setting id="failedCount" type="number" visible="false" default="0" />
 	    <setting id="networkCreds" type="text" visible="false" default="" />

From 6cb056c987eb9ec86e30bea615dbbb4683385409 Mon Sep 17 00:00:00 2001
From: A69Tor <algorath69tor@gmail.com>
Date: Fri, 6 May 2016 16:24:23 -0400
Subject: [PATCH 3/9] Update playutils.py

Add in videoprofile check and force transcode for Hi10P
---
 resources/lib/playutils.py | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/resources/lib/playutils.py b/resources/lib/playutils.py
index 622781d2..7f5b6926 100644
--- a/resources/lib/playutils.py
+++ b/resources/lib/playutils.py
@@ -102,7 +102,12 @@ class PlayUtils():
 
         videotrack = self.item['MediaSources'][0]['Name']
         transcodeH265 = settings('transcodeH265')
+        videoprofile = self.item['MediaSources'][1]['Name']
+        transcodeHi10P = settings('transcodeHi10P')        
 
+        if transcodeHi10P == "true" and "H264" in videotrack and "High 10" in videoprofile:
+            return False
+            
         if transcodeH265 in ("1", "2", "3") and ("HEVC" in videotrack or "H265" in videotrack):
             # Avoid H265/HEVC depending on the resolution
             resolution = int(videotrack.split("P", 1)[0])
@@ -207,6 +212,11 @@ class PlayUtils():
 
         videotrack = self.item['MediaSources'][0]['Name']
         transcodeH265 = utils.settings('transcodeH265')
+        videoprofile = self.item['MediaSources'][1]['Name']
+        transcodeHi10P = settings('transcodeHi10P')        
+
+        if transcodeHi10P == "true" and "H264" in videotrack and "High 10" in videoprofile:
+            return False        
 
         if transcodeH265 in ("1", "2", "3") and ("HEVC" in videotrack or "H265" in videotrack):
             # Avoid H265/HEVC depending on the resolution
@@ -423,4 +433,4 @@ class PlayUtils():
         else:
             playurlprefs += "&AudioBitrate=192000"
 
-        return playurlprefs
\ No newline at end of file
+        return playurlprefs

From d99e7a12906b5e014a2798178c44bb84f3bea6be Mon Sep 17 00:00:00 2001
From: A69Tor <algorath69tor@gmail.com>
Date: Fri, 6 May 2016 16:41:37 -0400
Subject: [PATCH 4/9] Update playutils.py

---
 resources/lib/playutils.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/resources/lib/playutils.py b/resources/lib/playutils.py
index 7f5b6926..4cf65f16 100644
--- a/resources/lib/playutils.py
+++ b/resources/lib/playutils.py
@@ -102,7 +102,7 @@ class PlayUtils():
 
         videotrack = self.item['MediaSources'][0]['Name']
         transcodeH265 = settings('transcodeH265')
-        videoprofile = self.item['MediaSources'][1]['Name']
+        videoprofile = self.item['MediaSources'][0]['Profile']
         transcodeHi10P = settings('transcodeHi10P')        
 
         if transcodeHi10P == "true" and "H264" in videotrack and "High 10" in videoprofile:
@@ -212,7 +212,7 @@ class PlayUtils():
 
         videotrack = self.item['MediaSources'][0]['Name']
         transcodeH265 = utils.settings('transcodeH265')
-        videoprofile = self.item['MediaSources'][1]['Name']
+        videoprofile = self.item['MediaSources'][0]['Profile']
         transcodeHi10P = settings('transcodeHi10P')        
 
         if transcodeHi10P == "true" and "H264" in videotrack and "High 10" in videoprofile:

From 7bf0912a111f86908e1c8671b0b0076024ddc642 Mon Sep 17 00:00:00 2001
From: A69Tor <algorath69tor@gmail.com>
Date: Fri, 6 May 2016 16:46:30 -0400
Subject: [PATCH 5/9] Update playutils.py

debug
---
 resources/lib/playutils.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/resources/lib/playutils.py b/resources/lib/playutils.py
index 4cf65f16..da3ff008 100644
--- a/resources/lib/playutils.py
+++ b/resources/lib/playutils.py
@@ -18,7 +18,7 @@ class PlayUtils():
     def __init__(self, item):
 
         self.item = item
-
+        self.logMsg(self.item)
         self.clientInfo = clientinfo.ClientInfo()
         self.addonName = self.clientInfo.getAddonName()
 

From db8ddc16d2c278d59e64bbb28c8cbe14911114f1 Mon Sep 17 00:00:00 2001
From: A69Tor <algorath69tor@gmail.com>
Date: Fri, 6 May 2016 18:00:52 -0400
Subject: [PATCH 6/9] Update settings.xml

Correct Bool for Transcode Hi10P
---
 resources/settings.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/resources/settings.xml b/resources/settings.xml
index 6deb4810..77d57a33 100644
--- a/resources/settings.xml
+++ b/resources/settings.xml
@@ -55,7 +55,7 @@
 	    <setting id="playFromStream" type="bool" label="30002" default="false" />
 	    <setting id="videoBitrate" type="enum" label="30160" values="664 Kbps SD|996 Kbps HD|1.3 Mbps HD|2.0 Mbps HD|3.2 Mbps HD|4.7 Mbps HD|6.2 Mbps HD|7.7 Mbps HD|9.2 Mbps HD|10.7 Mbps HD|12.2 Mbps HD|13.7 Mbps HD|15.2 Mbps HD|16.7 Mbps HD|18.2 Mbps HD|20.0 Mbps HD|40.0 Mbps HD|100.0 Mbps HD [default]|1000.0 Mbps HD" visible="true" default="17" subsetting="true" />
 	    <setting id="transcodeH265" type="enum" label="30522" default="0" values="Disabled|480p(and higher)|720p(and higher)|1080p" />
-	    <setting id="transcodeHi10P" type="bool" label="30537" visible="eq(-1,true)" default="false" subsetting="true" />	    
+	    <setting id="transcodeHi10P" type="bool" label="30537" default="false"/>	    
 	    <setting id="markPlayed" type="number" visible="false" default="90" />
 	    <setting id="failedCount" type="number" visible="false" default="0" />
 	    <setting id="networkCreds" type="text" visible="false" default="" />

From 9d50c4f74526e6afeeb7dbc7589eb1cfc1a66e69 Mon Sep 17 00:00:00 2001
From: A69Tor <algorath69tor@gmail.com>
Date: Fri, 6 May 2016 18:55:14 -0400
Subject: [PATCH 7/9] Update playutils.py

Modified Hi10P to get streams and parse profiles
---
 resources/lib/playutils.py | 28 ++++++++++++++++++----------
 1 file changed, 18 insertions(+), 10 deletions(-)

diff --git a/resources/lib/playutils.py b/resources/lib/playutils.py
index da3ff008..a6eff5ea 100644
--- a/resources/lib/playutils.py
+++ b/resources/lib/playutils.py
@@ -102,11 +102,15 @@ class PlayUtils():
 
         videotrack = self.item['MediaSources'][0]['Name']
         transcodeH265 = settings('transcodeH265')
-        videoprofile = self.item['MediaSources'][0]['Profile']
-        transcodeHi10P = settings('transcodeHi10P')        
-
-        if transcodeHi10P == "true" and "H264" in videotrack and "High 10" in videoprofile:
-            return False
+        videoprofiles = self.item['MediaSources'][0]['MediaStreams']
+        streamprofiles = []
+        for vprofile in videoprofiles:
+            if "Profile" in vprofile:
+                streamprofiles.append(vprofile['Profile'])
+        transcodeHi10P = utils.settings('transcodeHi10P')        
+        
+        if transcodeHi10P == "true" and "H264" in videotrack and "High 10" in streamprofiles:
+            return False   
             
         if transcodeH265 in ("1", "2", "3") and ("HEVC" in videotrack or "H265" in videotrack):
             # Avoid H265/HEVC depending on the resolution
@@ -212,11 +216,15 @@ class PlayUtils():
 
         videotrack = self.item['MediaSources'][0]['Name']
         transcodeH265 = utils.settings('transcodeH265')
-        videoprofile = self.item['MediaSources'][0]['Profile']
-        transcodeHi10P = settings('transcodeHi10P')        
-
-        if transcodeHi10P == "true" and "H264" in videotrack and "High 10" in videoprofile:
-            return False        
+        videoprofiles = self.item['MediaSources'][0]['MediaStreams']
+        streamprofiles = []
+        for vprofile in videoprofiles:
+            if "Profile" in vprofile:
+                streamprofiles.append(vprofile['Profile'])
+        transcodeHi10P = utils.settings('transcodeHi10P')        
+        
+        if transcodeHi10P == "true" and "H264" in videotrack and "High 10" in streamprofiles:
+            return False   
 
         if transcodeH265 in ("1", "2", "3") and ("HEVC" in videotrack or "H265" in videotrack):
             # Avoid H265/HEVC depending on the resolution

From 055366753a16d97f32bc4b1c96c50948c41b305c Mon Sep 17 00:00:00 2001
From: A69Tor <algorath69tor@gmail.com>
Date: Fri, 6 May 2016 18:57:19 -0400
Subject: [PATCH 8/9] Update playutils.py

Remove debug log line
---
 resources/lib/playutils.py | 1 -
 1 file changed, 1 deletion(-)

diff --git a/resources/lib/playutils.py b/resources/lib/playutils.py
index a6eff5ea..f8db1710 100644
--- a/resources/lib/playutils.py
+++ b/resources/lib/playutils.py
@@ -18,7 +18,6 @@ class PlayUtils():
     def __init__(self, item):
 
         self.item = item
-        self.logMsg(self.item)
         self.clientInfo = clientinfo.ClientInfo()
         self.addonName = self.clientInfo.getAddonName()
 

From 04377c5a9cf9b44a5c2325f94e69f9d4e3882a10 Mon Sep 17 00:00:00 2001
From: A69Tor <algorath69tor@gmail.com>
Date: Fri, 6 May 2016 19:16:07 -0400
Subject: [PATCH 9/9] Update playutils.py

Condense videoprofiles check
---
 resources/lib/playutils.py | 22 +++++++---------------
 1 file changed, 7 insertions(+), 15 deletions(-)

diff --git a/resources/lib/playutils.py b/resources/lib/playutils.py
index f8db1710..a1de2948 100644
--- a/resources/lib/playutils.py
+++ b/resources/lib/playutils.py
@@ -101,16 +101,12 @@ class PlayUtils():
 
         videotrack = self.item['MediaSources'][0]['Name']
         transcodeH265 = settings('transcodeH265')
-        videoprofiles = self.item['MediaSources'][0]['MediaStreams']
-        streamprofiles = []
-        for vprofile in videoprofiles:
-            if "Profile" in vprofile:
-                streamprofiles.append(vprofile['Profile'])
+        videoprofiles = [x['Profile'] for x in self.item['MediaSources'][0]['MediaStreams'] if 'Profile' in x]
         transcodeHi10P = utils.settings('transcodeHi10P')        
-        
-        if transcodeHi10P == "true" and "H264" in videotrack and "High 10" in streamprofiles:
+
+        if transcodeHi10P == "true" and "H264" in videotrack and "High 10" in videoprofiles:
             return False   
-            
+
         if transcodeH265 in ("1", "2", "3") and ("HEVC" in videotrack or "H265" in videotrack):
             # Avoid H265/HEVC depending on the resolution
             resolution = int(videotrack.split("P", 1)[0])
@@ -215,14 +211,10 @@ class PlayUtils():
 
         videotrack = self.item['MediaSources'][0]['Name']
         transcodeH265 = utils.settings('transcodeH265')
-        videoprofiles = self.item['MediaSources'][0]['MediaStreams']
-        streamprofiles = []
-        for vprofile in videoprofiles:
-            if "Profile" in vprofile:
-                streamprofiles.append(vprofile['Profile'])
+        videoprofiles = [x['Profile'] for x in self.item['MediaSources'][0]['MediaStreams'] if 'Profile' in x]
         transcodeHi10P = utils.settings('transcodeHi10P')        
-        
-        if transcodeHi10P == "true" and "H264" in videotrack and "High 10" in streamprofiles:
+
+        if transcodeHi10P == "true" and "H264" in videotrack and "High 10" in videoprofiles:
             return False   
 
         if transcodeH265 in ("1", "2", "3") and ("HEVC" in videotrack or "H265" in videotrack):