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

CanalPlus Extractor: Matcher exception not catched #2851

Closed
facke opened this issue May 4, 2014 · 2 comments
Closed

CanalPlus Extractor: Matcher exception not catched #2851

facke opened this issue May 4, 2014 · 2 comments

Comments

@facke
Copy link

@facke facke commented May 4, 2014

The canalplus extractor use mobj.group('id') to extract the video_id from the URL but it may not contain contain any ID which lead to AttributeException and stop the process.
The extractor should use the groupdict to get the potential id.

--- a/youtube_dl/extractor/canalplus.py
+++ b/youtube_dl/extractor/canalplus.py
@@ -26,7 +26,7 @@ class CanalplusIE(InfoExtractor):

     def _real_extract(self, url):
         mobj = re.match(self._VALID_URL, url)
-        video_id = mobj.group('id')
+        video_id = mobj.groupdict().get('id')

         if video_id is None:
             webpage = self._download_webpage(url, mobj.group('path'))
@phihag
Copy link
Contributor

@phihag phihag commented May 4, 2014

Thank you for the report. Can you add the full output you get when you
run youtube-dl (without the patch) with the --verbose option? That
output allows us to generate a testcase so that we can automatically
prevent this issue from ever happening again.

@facke
Copy link
Author

@facke facke commented May 4, 2014

Here an example:

youtube-dl -v  "http://www.d8.tv/d8-divertissement/ms-touche-pas-a-mon-poste/pid6318-videos-integrales.html?vid=1062920"
[debug] System config: []
[debug] User config: []
[debug] Command-line args: ['-v', 'http://www.d8.tv/d8-divertissement/ms-touche-pas-a-mon-poste/pid6318-videos-integrales.html?vid=1062920']
[debug] Encodings: locale UTF-8, fs UTF-8, out UTF-8, pref UTF-8
[debug] youtube-dl version 2014.04.30.1
[debug] Python version 2.7.5+ - Linux-2.6.32-x86_64
[debug] Proxy map: {}
Traceback (most recent call last):
  File "/usr/lib/python2.7/runpy.py", line 162, 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 18, in <module>
  File "/usr/local/bin/youtube-dl/youtube_dl/__init__.py", line 846, in main
  File "/usr/local/bin/youtube-dl/youtube_dl/__init__.py", line 836, in _real_main
  File "/usr/local/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 1039, in download
  File "/usr/local/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 516, in extract_info
  File "/usr/local/bin/youtube-dl/youtube_dl/extractor/common.py", line 161, in extract
  File "/usr/local/bin/youtube-dl/youtube_dl/extractor/canalplus.py", line 29, in _real_extract
IndexError: no such group

It's a logical error:

video_id = mobj.group('id') # video_id contain a value or an exception is thrown
if video_id is None: # Can not be triggered in any case! 
@phihag phihag closed this in 4de9e9a May 5, 2014
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
2 participants
You can’t perform that action at this time.