blackjack4494 / yt-dlc

media downloader and library for various sites.
The Unlicense
2.91k stars 368 forks source link

[YT] Fix --cookies option for Python 2.7 (works only with Python3) #236

Open someziggyman opened 3 years ago

someziggyman commented 3 years ago

Checklist

Verbose log

./dlctest -v -F --cookies cooktest.txt https://www.youtube.com/watch?v= XgnwCQzjau8
[debug] System config: []
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: [u'-v', u'-F', u'--cookies', u'cooktest.txt', u'https://www.youtube.com/watch?v= XgnwCQzjau8']
[debug] Loading archive file None
[debug] Encodings: locale UTF-8, fs utf-8, out UTF-8, pref UTF-8
[debug] youtube-dlc version 2020.11.11-2
[debug] Python version 2.7.16 (CPython) - Darwin-19.6.0-x86_64-i386-64bit
[debug] exe versions: none
[debug] Proxy map: {}
[youtube] XgnwCQzjau8: Downloading webpage
Traceback (most recent call last):
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 174, in _run_module_as_main
"main", fname, loader, pkg_name)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 72, in _run_code
exec code in run_globals
File "./dlctest/main.py", line 19, in
File "./dlctest/youtube_dlc/init.py", line 487, in main
File "./dlctest/youtube_dlc/init.py", line 477, in _real_main
File "./dlctest/youtube_dlc/YoutubeDL.py", line 2104, in download
File "./dlctest/youtube_dlc/YoutubeDL.py", line 830, in extract_info
File "./dlctest/youtube_dlc/extractor/common.py", line 532, in extract
File "./dlctest/youtube_dlc/extractor/youtube.py", line 1865, in _real_extract
File "./dlctest/youtube_dlc/extractor/common.py", line 2866, in get_cookies File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/Cookie.py", line 583, in init if input: self.load(input) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/Cookie.py", line 643, in load for k, v in rawdata.items(): AttributeError: 'unicode' object has no attribute 'items'

Description

This issue was described here https://github.com/blackjack4494/yt-dlc/issues/175#issuecomment-725942303 and --cookies option now works only on Python3.

Test link: https://www.youtube.com/watch?v=XgnwCQzjau8

nicolaasjan commented 3 years ago

Are there still systems that don't have Python3?

Why not make it so, that youtube-dlc first tries with Python3 and if that fails; only than use Python2 and throw an informative error message in case something fails? (it has never failed here with Python3)

On the newest Linux systems Python2 isn't even installed any more by default, so you have to e.g. use an alias like: alias youtube-dlc='python3 /usr/local/bin/youtube-dlc' for it to not throw the error: /usr/bin/env: ‘python’: No such file or directory I've seen several people with this issue on different forums...

someziggyman commented 3 years ago

Are there still systems that don't have Python3?

Why not make it so, that youtube-dlc first tries with Python3 and if that fails; only than use Python2 and throw an informative error message in case something fails? (it has never failed here with Python3)

On the newest Linux systems Python2 isn't even installed any more by default, so you have to e.g. use an alias like: alias youtube-dlc='python3 /usr/local/bin/youtube-dlc' for it to not throw the error: /usr/bin/env: ‘python’: No such file or directory I've seen several people with this issue on different forums...

All MacOS versions come with Python 2.7 out of the box. Installing Python 3 is another step that many new folks may find cumbersome and confusing.

nicolaasjan commented 3 years ago

All MacOS versions come with Python 2.7 out of the box.

Ah..., didn't know that. Strange... So MacOS doesn't even use the latest and greatest? ;)

Guess they have to learn to live with limited functionality.

samoht0 commented 3 years ago

All MacOS versions come with Python 2.7 out of the box. Installing Python 3 is another step that many new folks may find cumbersome and confusing.

"You should upgrade to Python 3 as soon as you can." https://www.python.org/doc/sunset-python-2/

Seriously, don't expect support for EOL software. Some ready-to-merge PR might might get merged, yeah. The interesting question for me is, if apple even cares to back-port security fixes. Guess not.

diegorodriguezv commented 3 years ago

I would recommend to stop supporting python 2. It has caused decades of headaches to the community and we have to draw a line somewhere. For more information please see: https://python3statement.org/ https://pythonclock.org/ If enough projects drop support for python 2, pressure will add up to force stragglers to update.

vxbinaca commented 3 years ago

Are there still systems that don't have Python3? Why not make it so, that youtube-dlc first tries with Python3 and if that fails; only than use Python2 and throw an informative error message in case something fails? (it has never failed here with Python3) On the newest Linux systems Python2 isn't even installed any more by default, so you have to e.g. use an alias like: alias youtube-dlc='python3 /usr/local/bin/youtube-dlc' for it to not throw the error: /usr/bin/env: ‘python’: No such file or directory I've seen several people with this issue on different forums...

All MacOS versions come with Python 2.7 out of the box. Installing Python 3 is another step that many new folks may find cumbersome and confusing.

Ports etc etc have python3. Let PYthon 2 die. Kill it if you have to.