Skip to content

Commit

Permalink
[youtube] more detailed logging of stream formats
Browse files Browse the repository at this point in the history
  • Loading branch information
soimort committed Jun 25, 2024
1 parent ed3f488 commit 0c216b3
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/you_get/extractors/youtube.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,9 @@ def prepare(self, **kwargs):
stream_list = ytInitialPlayerResponse['streamingData']['formats']

for stream in stream_list:
logging.debug('Found format: itag=%s' % stream['itag'])
if 'signatureCipher' in stream:
logging.debug('Parsing signatureCipher for itag=%s...' % stream['itag'])
logging.debug(' Parsing signatureCipher for itag=%s...' % stream['itag'])
qs = parse_qs(stream['signatureCipher'])
#logging.debug(qs)
sp = qs['sp'][0]
Expand All @@ -233,7 +234,7 @@ def prepare(self, **kwargs):
elif 'url' in stream:
url = stream['url']
else:
log.wtf('No signatureCipher or url for itag=%s' % stream['itag'])
log.wtf(' No signatureCipher or url for itag=%s' % stream['itag'])
url = self.__class__.dethrottle(self.js, url)

self.streams[str(stream['itag'])] = {
Expand Down Expand Up @@ -285,15 +286,19 @@ def prepare(self, **kwargs):
streams = [stream for stream in streams if 'contentLength' in stream]

for stream in streams:
logging.debug('Found adaptiveFormat: itag=%s' % stream['itag'])
stream['itag'] = str(stream['itag'])
if 'qualityLabel' in stream:
stream['quality_label'] = stream['qualityLabel']
del stream['qualityLabel']
logging.debug(' quality_label: \t%s' % stream['quality_label'])
if 'width' in stream:
stream['size'] = '{}x{}'.format(stream['width'], stream['height'])
del stream['width']
del stream['height']
logging.debug(' size: \t%s' % stream['size'])
stream['type'] = stream['mimeType']
logging.debug(' type: \t%s' % stream['type'])
stream['clen'] = stream['contentLength']
stream['init'] = '{}-{}'.format(
stream['initRange']['start'],
Expand All @@ -307,7 +312,7 @@ def prepare(self, **kwargs):
del stream['indexRange']

if 'signatureCipher' in stream:
logging.debug('Parsing signatureCipher for itag=%s...' % stream['itag'])
logging.debug(' Parsing signatureCipher for itag=%s...' % stream['itag'])
qs = parse_qs(stream['signatureCipher'])
#logging.debug(qs)
sp = qs['sp'][0]
Expand Down

0 comments on commit 0c216b3

Please sign in to comment.