Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CloudFlareStream: binascii.Error: Incorrect padding #26640

Open
5 tasks done
boolbag opened this issue Sep 20, 2020 · 8 comments
Open
5 tasks done

CloudFlareStream: binascii.Error: Incorrect padding #26640

boolbag opened this issue Sep 20, 2020 · 8 comments

Comments

@boolbag
Copy link

boolbag commented Sep 20, 2020

  • I'm reporting a broken site support
  • I've verified that I'm running youtube-dl version 2020.09.20
  • I've checked that all provided URLs are alive and playable in a browser
  • I've checked that all URLs and arguments with special characters are properly quoted or escaped
  • I've searched the bugtracker for similar issues including closed ones

Verbose log

[debug] System config: []
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: ['-v', 'https://watch.cloudflarestream.com/eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJraWQiOiJmYTA0YjViMzQ2NDkwYTM5NWJiNzQ1NWFhZTA2YzYwZSIsInN1YiI6Ijg4ZDQxMDhhMzY0MjA3M2VhYmFhZjg3ZGExODJkMjYzIiwiZXhwIjoxNjAwNjA5MzE5fQ.xkRJwLGkt0nZ%5F0BlPiwU7iW4pqb4lKkznbKfAhGg0tGcxSS6ZBA3lcTUwu7W%2DyCFbnAl%2Dhqk3Fn%5FqeQS%5FQydP27qTHpB9iIFFsMtk1tqzGZV5v4yrYDnwLSKzEKvVd6QwJnfABtxH2JdpSNuWlMUiVXFxGWgjOw6QeTNDDklTQYXV%5FNLV7sErSn5CeOPeRRkdXb%2D8ip%5FVOcfk1nDsFoOo4fctFtGP0wYMyY5ae8nhhatydHwevuvJCcEvEfh%2D4qjq9mCZOodevmtSQ4YWmggf4BxtWnDWYrGW8Otp6oqezrR8oY4%2DbKdV6PaqBj49aJdcls6xK7PmM8%5Fvjy3xfm0Mg']
[debug] Encodings: locale cp1252, fs mbcs, out cp437, pref cp1252
[debug] youtube-dl version 2020.09.20
[debug] Python version 3.4.4 (CPython) - Windows-10-10.0.18362
[debug] exe versions: none
[debug] Proxy map: {}
Traceback (most recent call last):
  File "__main__.py", line 19, in <module>
  File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\ytdl-org\tmpksi3o1r1\build\youtube_dl\__init__.py", line 474, in main
  File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\ytdl-org\tmpksi3o1r1\build\youtube_dl\__init__.py", line 464, in _real_main
  File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\ytdl-org\tmpksi3o1r1\build\youtube_dl\YoutubeDL.py", line 2019, in download
  File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\ytdl-org\tmpksi3o1r1\build\youtube_dl\YoutubeDL.py", line 797, in extract_info
  File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\ytdl-org\tmpksi3o1r1\build\youtube_dl\extractor\common.py", line 532, in extract
  File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\ytdl-org\tmpksi3o1r1\build\youtube_dl\extractor\cloudflarestream.py", line 57, in _real_extract
  File "C:\Python\Python34\lib\base64.py", line 135, in urlsafe_b64decode
  File "C:\Python\Python34\lib\base64.py", line 90, in b64decode
binascii.Error: Incorrect padding

Description

Video plays in browser but generates error in youtube-dl.

@parrukeisari
Copy link

parrukeisari commented May 20, 2021

I stumbled accross this one as well and did some digging. Looks like this is caused by cloudflare not properly padding the base64 encoded data that end up in video_id.

A workable fix is to add
import math
to cloudflarestream.py and replace line 57 in the same file with this:
video_id.split('.')[1].ljust(math.ceil(len(video_id.split('.')[1])/4)*4, '=')

Basically we'll just pad the string going to urlsafe_b64decode ourselves so that the decoder is happy.

@jacobkoziej
Copy link

I stumbled accross this one as well and did some digging. Looks like this is caused by cloudflare not properly padding the base64 encoded data that end up in video_id.

A workable fix is to add
import math
to cloudflarestream.py and replace line 57 in the same file with this:
video_id.split('.')[1].ljust(math.ceil(len(video_id.split('.')[1])/4)*4, '=')

Basically we'll just pad the string going to urlsafe_b64decode ourselves so that the decoder is happy.

Awesome! This fixed the issue on my end :)

@covix
Copy link

covix commented Mar 29, 2022

great! it worked for me as well!
Is there a reason this was not fixed in a more recent release?

Thanks anyway!!

@PhilPhonic
Copy link

PhilPhonic commented Apr 2, 2022

Having the same problem but the fix mentioned here does not work for me.
Any chance anyone could create a working fork of this?

nvm.. python2 was my problem here

@covix
Copy link

covix commented Apr 5, 2022

Having the same problem but the fix mentioned here does not work for me. Any chance anyone could create a working fork of this? nvm.. python2 was my problem here

Do you mean that the problem persisted also with python3 and that the proposed solution fixed it?

@PhilPhonic
Copy link

with python3 the proposed solution fixed it ;)

@covix
Copy link

covix commented Apr 6, 2022

with python3 the proposed solution fixed it ;)

Great! would you please post the link of the video you were trying to download? To replicate the error for later submitting a PR

@PhilPhonic
Copy link

Great! would you please post the link of the video you were trying to download? To replicate the error for later submitting a PR

sorry, that link has rotated out of my bash history

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants