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

[Twitter] Tweet Without Video Causing NoneType Attribute Errors #28909

Closed
5 tasks done
George-lewis opened this issue Apr 29, 2021 · 0 comments
Closed
5 tasks done

[Twitter] Tweet Without Video Causing NoneType Attribute Errors #28909

George-lewis opened this issue Apr 29, 2021 · 0 comments

Comments

@George-lewis
Copy link

George-lewis commented Apr 29, 2021

Checklist

  • I'm reporting a broken site support
  • I've verified that I'm running youtube-dl version 2021.04.26
  • 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

Long paths have been shortened with ...

[debug] System config: []
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: ['-v', 'https://twitter.com/Bluper/status/1387489813796954119']
[debug] Encodings: locale cp1252, fs utf-8, out utf-8, pref cp1252
[debug] youtube-dl version 2021.04.26
[debug] Git HEAD: 94520568b
[debug] Python version 3.9.4 (CPython) - Windows-10-10.0.19041-SP0
[debug] exe versions: ffmpeg 4.3.2-2021-02-20-essentials_build-www.gyan.dev, ffprobe 4.3.2-2021-02-20-essentials_build-www.gyan.dev
[debug] Proxy map: {}
[twitter] 1387489813796954119: Downloading guest token
[twitter] 1387489813796954119: Downloading JSON metadata
[twitter] 1387489813796954119: Downloading XML
Traceback (most recent call last):
  File "C:\Python39\lib\runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Python39\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "...\youtube-dl\youtube_dl\__main__.py", line 21, in <module>
    youtube_dl.main()
  File "...\youtube-dl\youtube_dl\__init__.py", line 475, in main
    _real_main(argv)
  File "...\youtube-dl\youtube_dl\__init__.py", line 465, in _real_main
    retcode = ydl.download(all_urls)
  File "...\youtube-dl\youtube_dl\YoutubeDL.py", line 2059, in download
    res = self.extract_info(
  File "...\youtube-dl\youtube_dl\YoutubeDL.py", line 799, in extract_info
    return self.__extract_info(url, ie, download, extra_info, process)
  File "...\youtube-dl\youtube_dl\YoutubeDL.py", line 806, in wrapper
    return func(self, *args, **kwargs)
  File "...\youtube-dl\youtube_dl\YoutubeDL.py", line 827, in __extract_info
    ie_result = ie.extract(url)
  File "...\youtube-dl\youtube_dl\extractor\common.py", line 534, in extract
    ie_result = self._real_extract(url)
  File "...\youtube-dl\youtube_dl\extractor\twitter.py", line 545, in _real_extract
    formats = self._extract_formats_from_vmap_url(vmap_url, content_id or twid)
  File "...\youtube-dl\youtube_dl\extractor\twitter.py", line 55, in _extract_formats_from_vmap_url
    vmap_data = self._download_xml(vmap_url, video_id)
  File "...\youtube-dl\youtube_dl\extractor\common.py", line 845, in _download_xml
    res = self._download_xml_handle(
    res = self._download_webpage_handle(
  File "...\youtube-dl\youtube_dl\extractor\common.py", line 667, in _download_webpage_handle
    urlh = self._request_webpage(url_or_request, video_id, note, errnote, fatal, data=data, headers=headers, query=query, expected_status=expected_status)
  File "...\youtube-dl\youtube_dl\extractor\common.py", line 634, in _request_webpage
    return self._downloader.urlopen(url_or_request)
  File "...\youtube-dl\youtube_dl\YoutubeDL.py", line 2279, in urlopen
    return self._opener.open(req, timeout=self._socket_timeout)
  File "C:\Python39\lib\urllib\request.py", line 507, in open
    req.timeout = timeout
AttributeError: 'NoneType' object has no attribute 'timeout'

Description

It seems that under certain situations involving Tweets without video the Twitter extractor will call into Urllib with a None url, causing an AttributeError.

Here is the tweet that causes the issue. It is as simple to reproduce as just calling YDL 2021.04.26 with this tweet as the argument.

I have dug through the code a little and found that the extractor seems to get the url on line 541 and that this is where the trouble starts to manifest. That None url is passed down several functions eventually ending up in common.py where it crosses over into library code.

I would be happy to submit a pull request myself. Would something like this be sufficient?:

...
is_amplify = card_name == 'amplify'
vmap_url = get_binding_value('amplify_url_vmap') if is_amplify else get_binding_value('player_stream_url')

if vmap_url is None:
    raise ExtractorError("There's no video in this tweet.")
...

Thanks.

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

1 participant