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

Use proper error handling for subtitles #914

Open
jaimeMF opened this issue Jun 23, 2013 · 3 comments
Open

Use proper error handling for subtitles #914

jaimeMF opened this issue Jun 23, 2013 · 3 comments
Assignees

Comments

@jaimeMF
Copy link
Collaborator

@jaimeMF jaimeMF commented Jun 23, 2013

Each IE that extract subtitles should handle the errors internally.
If they are not available, it should report a warning, and if it finds them, set the dictionary of subtitles. The main goal is to stop using tuples for handling errors.

See this weird error from a Travis test (https://travis-ci.org/rg3/youtube-dl/jobs/83670969):

ERROR: test_youtube_list_subtitles (test_youtube_subtitles.TestYoutubeSubtitles)
----------------------------------------------------------------------

Traceback (most recent call last):

File "/home/travis/build/rg3/youtube-dl/test/test_youtube_subtitles.py", line 99, in test_youtube_list_subtitles

info_dict = IE.extract('QRS8MkLhQmM')

File "/home/travis/build/rg3/youtube-dl/youtube_dl/extractor/common.py", line 91, in extract

return self._real_extract(url)

File "/home/travis/build/rg3/youtube-dl/youtube_dl/extractor/youtube.py", line 473, in _real_extract

self._list_available_subtitles(video_id)

File "/home/travis/build/rg3/youtube-dl/youtube_dl/extractor/youtube.py", line 158, in _list_available_subtitles

self.report_video_subtitles_available(video_id, sub_lang_list)

File "/home/travis/build/rg3/youtube-dl/youtube_dl/extractor/youtube.py", line 117, in report_video_subtitles_available

sub_lang = ",".join(list(sub_lang_list.keys()))

AttributeError: 'tuple' object has no attribute 'keys'
@ghost ghost assigned jaimeMF Jun 23, 2013
@FiloSottile
Copy link
Collaborator

@FiloSottile FiloSottile commented Jun 25, 2013

Related: I'm occasionally getting this ton of errors with subtitles.

They are at least very unstable.

======================================================================
ERROR: test_youtube_list_subtitles (test_youtube_subtitles.TestYoutubeSubtitles)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/filosottile/git/youtube-dl/test/test_youtube_subtitles.py", line 99, in test_youtube_list_subtitles
    info_dict = IE.extract('QRS8MkLhQmM')
  File "/Users/filosottile/git/youtube-dl/youtube_dl/extractor/common.py", line 91, in extract
    return self._real_extract(url)
  File "/Users/filosottile/git/youtube-dl/youtube_dl/extractor/youtube.py", line 473, in _real_extract
    self._list_available_subtitles(video_id)
  File "/Users/filosottile/git/youtube-dl/youtube_dl/extractor/youtube.py", line 158, in _list_available_subtitles
    self.report_video_subtitles_available(video_id, sub_lang_list)
  File "/Users/filosottile/git/youtube-dl/youtube_dl/extractor/youtube.py", line 117, in report_video_subtitles_available
    sub_lang = ",".join(list(sub_lang_list.keys()))
AttributeError: 'tuple' object has no attribute 'keys'
-------------------- >> begin captured stdout << ---------------------
[youtube] Setting language
[youtube] QRS8MkLhQmM: Downloading video webpage
[youtube] QRS8MkLhQmM: Downloading video info webpage
[youtube] QRS8MkLhQmM: Extracting video information
[youtube] QRS8MkLhQmM: Checking available subtitles

--------------------- >> end captured stdout << ----------------------

======================================================================
ERROR: test_youtube_onlysubtitles (test_youtube_subtitles.TestYoutubeSubtitles)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/filosottile/git/youtube-dl/test/test_youtube_subtitles.py", line 77, in test_youtube_onlysubtitles
    info_dict = IE.extract('QRS8MkLhQmM')
  File "/Users/filosottile/git/youtube-dl/youtube_dl/extractor/common.py", line 91, in extract
    return self._real_extract(url)
  File "/Users/filosottile/git/youtube-dl/youtube_dl/extractor/youtube.py", line 457, in _real_extract
    video_subtitles = self._request_automatic_caption(video_id, video_webpage)
  File "/Users/filosottile/git/youtube-dl/youtube_dl/extractor/youtube.py", line 204, in _request_automatic_caption
    sub = self._download_webpage(subtitles_url, video_id, u'Downloading automatic captions')
  File "/Users/filosottile/git/youtube-dl/youtube_dl/extractor/common.py", line 145, in _download_webpage
    return self._download_webpage_handle(url_or_request, video_id, note, errnote)[0]
  File "/Users/filosottile/git/youtube-dl/youtube_dl/extractor/common.py", line 124, in _download_webpage_handle
    urlh = self._request_webpage(url_or_request, video_id, note, errnote)
  File "/Users/filosottile/git/youtube-dl/youtube_dl/extractor/common.py", line 120, in _request_webpage
    raise ExtractorError(u'%s: %s' % (errnote, compat_str(err)), sys.exc_info()[2])
ExtractorError: Unable to download webpage: HTTP Error 404: Not Found; please report this issue on GitHub.
-------------------- >> begin captured stdout << ---------------------
[youtube] Setting language
[youtube] QRS8MkLhQmM: Downloading video webpage
[youtube] QRS8MkLhQmM: Downloading video info webpage
[youtube] QRS8MkLhQmM: Extracting video information
[youtube] QRS8MkLhQmM: Checking available subtitles
[youtube] QRS8MkLhQmM: Looking for automatic captions
[youtube] QRS8MkLhQmM: Downloading automatic captions

--------------------- >> end captured stdout << ----------------------; please report this issue on GitHub.

======================================================================
ERROR: test_youtube_subtitles_format (test_youtube_subtitles.TestYoutubeSubtitles)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/filosottile/git/youtube-dl/test/test_youtube_subtitles.py", line 92, in test_youtube_subtitles_format
    info_dict = IE.extract('QRS8MkLhQmM')
  File "/Users/filosottile/git/youtube-dl/youtube_dl/extractor/common.py", line 91, in extract
    return self._real_extract(url)
  File "/Users/filosottile/git/youtube-dl/youtube_dl/extractor/youtube.py", line 457, in _real_extract
    video_subtitles = self._request_automatic_caption(video_id, video_webpage)
  File "/Users/filosottile/git/youtube-dl/youtube_dl/extractor/youtube.py", line 204, in _request_automatic_caption
    sub = self._download_webpage(subtitles_url, video_id, u'Downloading automatic captions')
  File "/Users/filosottile/git/youtube-dl/youtube_dl/extractor/common.py", line 145, in _download_webpage
    return self._download_webpage_handle(url_or_request, video_id, note, errnote)[0]
  File "/Users/filosottile/git/youtube-dl/youtube_dl/extractor/common.py", line 124, in _download_webpage_handle
    urlh = self._request_webpage(url_or_request, video_id, note, errnote)
  File "/Users/filosottile/git/youtube-dl/youtube_dl/extractor/common.py", line 120, in _request_webpage
    raise ExtractorError(u'%s: %s' % (errnote, compat_str(err)), sys.exc_info()[2])
ExtractorError: Unable to download webpage: HTTP Error 404: Not Found; please report this issue on GitHub.
-------------------- >> begin captured stdout << ---------------------
[youtube] Setting language
[youtube] QRS8MkLhQmM: Downloading video webpage
[youtube] QRS8MkLhQmM: Downloading video info webpage
[youtube] QRS8MkLhQmM: Extracting video information
[youtube] QRS8MkLhQmM: Checking available subtitles
[youtube] QRS8MkLhQmM: Looking for automatic captions
[youtube] QRS8MkLhQmM: Downloading automatic captions

--------------------- >> end captured stdout << ----------------------; please report this issue on GitHub.

======================================================================
ERROR: test_youtube_subtitles_it (test_youtube_subtitles.TestYoutubeSubtitles)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/filosottile/git/youtube-dl/test/test_youtube_subtitles.py", line 69, in test_youtube_subtitles_it
    info_dict = IE.extract('QRS8MkLhQmM')
  File "/Users/filosottile/git/youtube-dl/youtube_dl/extractor/common.py", line 91, in extract
    return self._real_extract(url)
  File "/Users/filosottile/git/youtube-dl/youtube_dl/extractor/youtube.py", line 457, in _real_extract
    video_subtitles = self._request_automatic_caption(video_id, video_webpage)
  File "/Users/filosottile/git/youtube-dl/youtube_dl/extractor/youtube.py", line 204, in _request_automatic_caption
    sub = self._download_webpage(subtitles_url, video_id, u'Downloading automatic captions')
  File "/Users/filosottile/git/youtube-dl/youtube_dl/extractor/common.py", line 145, in _download_webpage
    return self._download_webpage_handle(url_or_request, video_id, note, errnote)[0]
  File "/Users/filosottile/git/youtube-dl/youtube_dl/extractor/common.py", line 124, in _download_webpage_handle
    urlh = self._request_webpage(url_or_request, video_id, note, errnote)
  File "/Users/filosottile/git/youtube-dl/youtube_dl/extractor/common.py", line 120, in _request_webpage
    raise ExtractorError(u'%s: %s' % (errnote, compat_str(err)), sys.exc_info()[2])
ExtractorError: Unable to download webpage: HTTP Error 404: Not Found; please report this issue on GitHub.
-------------------- >> begin captured stdout << ---------------------
[youtube] Setting language
[youtube] QRS8MkLhQmM: Downloading video webpage
[youtube] QRS8MkLhQmM: Downloading video info webpage
[youtube] QRS8MkLhQmM: Extracting video information
[youtube] QRS8MkLhQmM: Checking available subtitles
[youtube] QRS8MkLhQmM: Looking for automatic captions
[youtube] QRS8MkLhQmM: Downloading automatic captions

--------------------- >> end captured stdout << ----------------------; please report this issue on GitHub.

======================================================================
FAIL: test_youtube_allsubtitles (test_youtube_subtitles.TestYoutubeSubtitles)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/filosottile/git/youtube-dl/test/test_youtube_subtitles.py", line 86, in test_youtube_allsubtitles
    self.assertEqual(len(subtitles), 13)
AssertionError: 1 != 13
-------------------- >> begin captured stdout << ---------------------
[youtube] Setting language
[youtube] QRS8MkLhQmM: Downloading video webpage
[youtube] QRS8MkLhQmM: Downloading video info webpage
[youtube] QRS8MkLhQmM: Extracting video information
[youtube] QRS8MkLhQmM: Checking available subtitles
[youtube] QRS8MkLhQmM: Vevo video detected.

--------------------- >> end captured stdout << ----------------------
@jaimeMF
Copy link
Collaborator Author

@jaimeMF jaimeMF commented Jun 25, 2013

It also happens to me sometimes, the first thing I'll do is disable automatic captions by default and then use dictionaries everywhere (at least the error messages will make sense). The most strange error is the one trying to download all the subtitles, I gess it doesn't find subtitles and we end with just a tuple with the error message.

@LAP2008
Copy link

@LAP2008 LAP2008 commented Jun 26, 2013

this Error you have with the subtitles looks similar to the error i get in Issue #930 Except im trying to download Videos

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

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.