Skip to content

Commit

Permalink
Merge pull request #155 from anxdpanic/pr_isengard
Browse files Browse the repository at this point in the history
fixups
  • Loading branch information
anxdpanic authored Jun 19, 2021
2 parents 9864dcb + a05112c commit 574439a
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 13 deletions.
13 changes: 4 additions & 9 deletions addon.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,10 @@
<extension point="xbmc.python.module" library="resources/lib/"/>
<extension point="xbmc.addon.metadata">
<news>
6.8.14
[fixup] playback of some streams due to encoding issues
[fixup] default player response type

6.8.13
[fix] player config and client discovery
[fix] No Streams Found |contrib: 14mRh4X0r|
[fix] capability map to contain unversioned capabilities |contrib: jmbreuer|
[lang] zh_tw strings |contrib: JuenTingShie|
[fixup] No streams found, consent cookies |contrib: jaylinski|
[fixup] Age gate detection, show age gate error instead of 'No streams found'
[fixup] encoding of some titles/authors - ie. russian
[lang] translation updates from Weblate
</news>
<assets>
<icon>icon.png</icon>
Expand Down
6 changes: 6 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
6.8.15
[fixup] No streams found, consent cookies |contrib: jaylinski|
[fixup] Age gate detection, show age gate error instead of 'No streams found'
[fixup] encoding of some titles/authors - ie. russian
[lang] translation updates from Weblate

6.8.14
[fixup] playback of some streams due to encoding issues
[fixup] default player response type
Expand Down
20 changes: 16 additions & 4 deletions resources/lib/youtube_plugin/youtube/helper/video_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -551,12 +551,14 @@ def get_embed_page(self, video_id):
params = {'hl': self.language,
'gl': self.region}

cookies = {'CONSENT': 'YES+cb.20210615-14-p0.en+FX+294'}

if self._access_token:
params['access_token'] = self._access_token

url = 'https://www.youtube.com/embed/{video_id}'.format(video_id=video_id)

result = requests.get(url, params=params, headers=headers, verify=self._verify, allow_redirects=True)
result = requests.get(url, params=params, headers=headers, cookies=cookies, verify=self._verify, allow_redirects=True)
return {'html': result.text, 'cookies': result.cookies}

@staticmethod
Expand Down Expand Up @@ -701,6 +703,10 @@ def requires_cipher(_fmts):

curl_headers = ''
cookies = page_result.get('cookies', {})
cookies.update({
'CONSENT': 'YES+cb.20210615-14-p0.en+FX+294'
})

if cookies:
cookies_list = list()
for c in cookies:
Expand Down Expand Up @@ -741,7 +747,9 @@ def requires_cipher(_fmts):
result = requests.get(video_info_url, params=http_params, headers=headers, cookies=cookies, verify=self._verify, allow_redirects=True)
data = result.text
params = dict(urllib.parse.parse_qsl(data))
player_response = json.loads(params.get('player_response', '{}'))
p_response = json.loads(params.get('player_response', '{}'))
if p_response:
player_response = p_response

playability_status = player_response.get('playabilityStatus', {})

Expand Down Expand Up @@ -772,8 +780,12 @@ def requires_cipher(_fmts):

if PY2:
try:
meta_info['video']['title'] = meta_info['video']['title'].decode('utf-8')
meta_info['channel']['author'] = meta_info['channel']['author'].decode('utf-8')
if r'\u' not in meta_info['video']['title']:
meta_info['video']['title'] = meta_info['video']['title'].decode('utf-8')
meta_info['channel']['author'] = meta_info['channel']['author'].decode('utf-8')
else:
meta_info['video']['title'] = meta_info['video']['title'].decode('raw_unicode_escape')
meta_info['channel']['author'] = meta_info['channel']['author'].decode('raw_unicode_escape')
except UnicodeDecodeError:
meta_info['video']['title'] = meta_info['video']['title'].decode('raw_unicode_escape')
meta_info['channel']['author'] = meta_info['channel']['author'].decode('raw_unicode_escape')
Expand Down

0 comments on commit 574439a

Please sign in to comment.