question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

HTTP 404 error on some streams

See original GitHub issue

version 9.5.1 I have 404 error on some streams from this video, and many other (1/10 of all videos from my big list), after download()

yt = YouTube('https://www.youtube.com/watch?v=8GPULK6XYhU')

[<Stream: itag="22" mime_type="video/mp4" res="720p" fps="30fps" vcodec="avc1.64001F" acodec="mp4a.40.2">,
 <Stream: itag="43" mime_type="video/webm" res="360p" fps="30fps" vcodec="vp8.0" acodec="vorbis">,
 <Stream: itag="18" mime_type="video/mp4" res="360p" fps="30fps" vcodec="avc1.42001E" acodec="mp4a.40.2">,
 <Stream: itag="137" mime_type="video/mp4" res="1080p" fps="30fps" vcodec="avc1.64001e">,
 <Stream: itag="248" mime_type="video/webm" res="1080p" fps="30fps" vcodec="vp9">,
 <Stream: itag="136" mime_type="video/mp4" res="720p" fps="30fps" vcodec="avc1.4d4016">...]

For example, first one is ok, but 4 and 6 are not. This is bug or something youtube related?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
FearlessENTcommented, Jul 20, 2019

@JuraPal I was reading through one of the previous issues, and the 403 problem has been fixed. The fix brings up a regex error, but that has also been fixed.

fixing 403: change line 42 and below to:

`if (‘signature=’ in url or (‘s’ not in stream and (‘&sig=’ in url or ‘&lsig=’ in url))): # For certain videos, YouTube will just provide them pre-signed, in # which case there’s no real magic to download them and we can skip # the whole signature descrambling entirely. logger.debug(‘signature found, skip decipher’) continue

    if js is not None:
        signature = cipher.get_signature(js, stream['s'])
    else:
        # signature not present in url (line 33), need js to descramble
        # TypeError caught in __main__
        raise TypeError('JS is None')

    logger.debug(
        'finished descrambling signature for itag=%s\n%s',
        stream['itag'], pprint.pformat(
            {
                's': stream['s'],
                'signature': signature,
            }, indent=2,
        ),
    )
    stream_manifest[i]['url'] = url + '&sig=' + signature`

This fixes the 403 error. Next issue is a regex problem.

Go to cipher.py and change line 38 to:

pattern = [ r'\b[cs]\s*&&\s*[adf]\.set\([^,]+\s*,\s*encodeURIComponent\s*\(\s*(?P<sig>[a-zA-Z0-9$]+)\(', r'\b[a-zA-Z0-9]+\s*&&\s*[a-zA-Z0-9]+\.set\([^,]+\s*,\s*encodeURIComponent\s*\(\s*(?P<sig>[a-zA-Z0-9$]+)\(', r'(?P<sig>[a-zA-Z0-9$]+)\s*=\s*function\(\s*a\s*\)\s*{\s*a\s*=\s*a\.split\(\s*""\s*\)', r'(["\'])signature\1\s*,\s*(?P<sig>[a-zA-Z0-9$]+)\(', r'\.sig\|\|(?P<sig>[a-zA-Z0-9$]+)\(', r'yt\.akamaized\.net/\)\s*\|\|\s*.*?\s*[cs]\s*&&\s*[adf]\.set\([^,]+\s*,\s*(?:encodeURIComponent\s*\()?\s*(?P<si$', r'\b[cs]\s*&&\s*[adf]\.set\([^,]+\s*,\s*(?P<sig>[a-zA-Z0-9$]+)\(', r'\b[a-zA-Z0-9]+\s*&&\s*[a-zA-Z0-9]+\.set\([^,]+\s*,\s*(?P<sig>[a-zA-Z0-9$]+)\(', r'\bc\s*&&\s*a\.set\([^,]+\s*,\s*\([^)]*\)\s*\(\s*(?P<sig>[a-zA-Z0-9$]+)\(', r'\bc\s*&&\s*[a-zA-Z0-9]+\.set\([^,]+\s*,\s*\([^)]*\)\s*\(\s*(?P<sig>[a-zA-Z0-9$]+)\(', r'\bc\s*&&\s*[a-zA-Z0-9]+\.set\([^,]+\s*,\s*\([^)]*\)\s*\(\s*(?P<sig>[a-zA-Z0-9$]+)\(' ]

This should fix the current issues.

0reactions
bhuiyanmobasshir94commented, Jul 3, 2021

pytube-10.8.5 got the fix in my machine

Read more comments on GitHub >

github_iconTop Results From Across the Web

404 Page Not Found Error: What It Is and How to Fix It - Lifewire
The 404 Not Found error, also called Error 404 or an HTTP 404 error, means that the web page you were trying to...
Read more >
What Is a 404 Error? How to Deal With the Web Error
A 404 error indicates that the webpage you're trying to reach can't be found, and usually means that the page has moved or...
Read more >
What Is a 404 Not Found Error? - Reviews.org
When you see a 404 Not Found error, it simply means that your computer is trying to access information on a page that...
Read more >
404 Page Not Found Error: What It Is and How to Fix It
The 404 Not Found error, also called Error 404 or an HTTP 404 error, means that the web page you were trying to...
Read more >
Server retured 404 not found · Issue #167 · xteve-project/xTeVe
Some streams return a 404 error while run thru Xteve. ... With Curl you can check every HTTP connection, including your streaming URLs....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found