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.

Youtube.com + cookies: 'unicode' object has no attribute 'items'

See original GitHub issue

Checklist

  • I’m reporting a broken site support issue
  • I’ve verified that I’m running youtube-dl version 2021.04.01
  • 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 bug reports including closed ones
  • I’ve read bugs section in FAQ

Verbose log

$ youtube-dl -v --cookies=/tmp/ytdljar.txt https://www.youtube.com/watch\?v\=vP3rYUNmrgU
[debug] System config: []
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: [u'-v', u'--cookies=/tmp/ytdljar.txt', u'https://www.youtube.com/watch?v=vP3rYUNmrgU']
[debug] Encodings: locale UTF-8, fs UTF-8, out UTF-8, pref UTF-8
[debug] youtube-dl version 2021.04.01
[debug] Python version 2.7.13 (CPython) - Linux-4.15.18-10-pve-x86_64-with-debian-9.13
[debug] exe versions: ffmpeg 3.3.9, ffprobe 3.3.9
[debug] Proxy map: {}
Traceback (most recent call last):
  File "/usr/lib/python2.7/runpy.py", line 174, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/usr/local/bin/youtube-dl/__main__.py", line 19, in <module>
  File "/usr/local/bin/youtube-dl/youtube_dl/__init__.py", line 475, in main
  File "/usr/local/bin/youtube-dl/youtube_dl/__init__.py", line 465, in _real_main
  File "/usr/local/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 2060, in download
  File "/usr/local/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 799, in extract_info
  File "/usr/local/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 806, in wrapper
  File "/usr/local/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 827, in __extract_info
  File "/usr/local/bin/youtube-dl/youtube_dl/extractor/common.py", line 533, in extract
  File "/usr/local/bin/youtube-dl/youtube_dl/extractor/common.py", line 437, in initialize
  File "/usr/local/bin/youtube-dl/youtube_dl/extractor/youtube.py", line 268, in _real_initialize
  File "/usr/local/bin/youtube-dl/youtube_dl/extractor/youtube.py", line 253, in _initialize_consent
  File "/usr/local/bin/youtube-dl/youtube_dl/extractor/common.py", line 2902, in _get_cookies
  File "/usr/lib/python2.7/Cookie.py", line 583, in __init__
    if input: self.load(input)
  File "/usr/lib/python2.7/Cookie.py", line 643, in load
    for k, v in rawdata.items():
AttributeError: 'unicode' object has no attribute 'items'


Description

Since as of two days ago, 31 March 2021, youtube.com stopped working when using cookies and youtube-dl version 2021.04.01 I tested the --username/--password parameters and indeed I can login and download videos.

So, I pulled the youtube-dl version 2021.03.31 and it was able to download videos using cookies. So something between 8f493de9fb3a7f123bdf887163efa06ce9d6b051 and ca304beb1538e54c5a18fdd50846ed2259d63b8c messed up the way cookies are being processed.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:13 (2 by maintainers)

github_iconTop GitHub Comments

9reactions
rautamiekkacommented, Apr 3, 2021

I can’t speak for non-Debian-type Linux distros, but there you can install the python-is-python3 package.

^ However, the problem’s that if anything uses Python 2-exclusive scripts, they’ll break. I know Ubuntu’s latest versions are using Python 3-exclusive scripts and Python 2 was relocated to multiverse repo (which is disabled by default IIRC), so Ubuntu is safe.

Alternatively you can make a shell alias like so:

##If in ${PATH}:
alias youtube-dl='python3 youtube-dl '

##If not in ${PATH}:
alias youtube-dl='python3 /path/to/youtube-dl '

Notice the trailing space !

2reactions
Suikacommented, Apr 3, 2021

Nice knowing all that, but the docs list support for python 2.6/2.7. Sadly it is still a bug that needs fixing, as it breaks that version “support”. But at least I know that it works with py3.

Read more comments on GitHub >

github_iconTop Results From Across the Web

AttributeError: 'unicode' object has no attribute 'items ... - Reddit
I'm using cookies.txt to get my cookies file. It works fine while downloading from youtube, but when downloading from twitch I get an...
Read more >
'Unicode' object has no attribute 'items' - Stack Overflow
In my case (youtube-dl), using python3 instead of python2 solved it. Maybe one of the involved .py files just uses a python3-ism.
Read more >
AttributeError: 'unicode' object has no attribute 'items' : youtubedl
AttributeError: 'unicode' object has no attribute 'items' : youtubedl ... _run_code exec code in run_globals File "/usr/local/bin/youtube-dl/__main__.py", ...
Read more >
'unicode' object has no attribute 'items' getting for post request ...
You received this message because you are subscribed to the Google Groups "robotframework-users" group. To unsubscribe from this group and stop receiving emails ......
Read more >
issue using cmds.getAttr() - Autodesk Community - Maya
I'm giving {} as the python object I want to have the attribute, isn't that an ... would not be this the way...
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