mirror of
				https://github.com/yt-dlp/yt-dlp.git
				synced 2025-11-04 08:35:12 +00:00 
			
		
		
		
	[vimeo] Fix pro videos and player.vimeo.com urls
The old process can still be used for those videos. Added RegexNotFoundError, which is raised by _search_regex if it can't extract the info.
This commit is contained in:
		@@ -14,6 +14,7 @@ from ..utils import (
 | 
				
			|||||||
    clean_html,
 | 
					    clean_html,
 | 
				
			||||||
    compiled_regex_type,
 | 
					    compiled_regex_type,
 | 
				
			||||||
    ExtractorError,
 | 
					    ExtractorError,
 | 
				
			||||||
 | 
					    RegexNotFoundError,
 | 
				
			||||||
    unescapeHTML,
 | 
					    unescapeHTML,
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -231,7 +232,7 @@ class InfoExtractor(object):
 | 
				
			|||||||
        Perform a regex search on the given string, using a single or a list of
 | 
					        Perform a regex search on the given string, using a single or a list of
 | 
				
			||||||
        patterns returning the first matching group.
 | 
					        patterns returning the first matching group.
 | 
				
			||||||
        In case of failure return a default value or raise a WARNING or a
 | 
					        In case of failure return a default value or raise a WARNING or a
 | 
				
			||||||
        ExtractorError, depending on fatal, specifying the field name.
 | 
					        RegexNotFoundError, depending on fatal, specifying the field name.
 | 
				
			||||||
        """
 | 
					        """
 | 
				
			||||||
        if isinstance(pattern, (str, compat_str, compiled_regex_type)):
 | 
					        if isinstance(pattern, (str, compat_str, compiled_regex_type)):
 | 
				
			||||||
            mobj = re.search(pattern, string, flags)
 | 
					            mobj = re.search(pattern, string, flags)
 | 
				
			||||||
@@ -251,7 +252,7 @@ class InfoExtractor(object):
 | 
				
			|||||||
        elif default is not None:
 | 
					        elif default is not None:
 | 
				
			||||||
            return default
 | 
					            return default
 | 
				
			||||||
        elif fatal:
 | 
					        elif fatal:
 | 
				
			||||||
            raise ExtractorError(u'Unable to extract %s' % _name)
 | 
					            raise RegexNotFoundError(u'Unable to extract %s' % _name)
 | 
				
			||||||
        else:
 | 
					        else:
 | 
				
			||||||
            self._downloader.report_warning(u'unable to extract %s; '
 | 
					            self._downloader.report_warning(u'unable to extract %s; '
 | 
				
			||||||
                u'please report this issue on http://yt-dl.org/bug' % _name)
 | 
					                u'please report this issue on http://yt-dl.org/bug' % _name)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -10,6 +10,7 @@ from ..utils import (
 | 
				
			|||||||
    clean_html,
 | 
					    clean_html,
 | 
				
			||||||
    get_element_by_attribute,
 | 
					    get_element_by_attribute,
 | 
				
			||||||
    ExtractorError,
 | 
					    ExtractorError,
 | 
				
			||||||
 | 
					    RegexNotFoundError,
 | 
				
			||||||
    std_headers,
 | 
					    std_headers,
 | 
				
			||||||
    unsmuggle_url,
 | 
					    unsmuggle_url,
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
@@ -133,6 +134,11 @@ class VimeoIE(InfoExtractor):
 | 
				
			|||||||
                r' data-config-url="(.+?)"', webpage, u'config URL')
 | 
					                r' data-config-url="(.+?)"', webpage, u'config URL')
 | 
				
			||||||
            config_json = self._download_webpage(config_url, video_id)
 | 
					            config_json = self._download_webpage(config_url, video_id)
 | 
				
			||||||
            config = json.loads(config_json)
 | 
					            config = json.loads(config_json)
 | 
				
			||||||
 | 
					        except RegexNotFoundError:
 | 
				
			||||||
 | 
					            # For pro videos or player.vimeo.com urls
 | 
				
			||||||
 | 
					            config = self._search_regex([r' = {config:({.+?}),assets:', r'c=({.+?);'],
 | 
				
			||||||
 | 
					                webpage, u'info section', flags=re.DOTALL)
 | 
				
			||||||
 | 
					            config = json.loads(config)
 | 
				
			||||||
        except Exception as e:
 | 
					        except Exception as e:
 | 
				
			||||||
            if re.search('The creator of this video has not given you permission to embed it on this domain.', webpage):
 | 
					            if re.search('The creator of this video has not given you permission to embed it on this domain.', webpage):
 | 
				
			||||||
                raise ExtractorError(u'The author has restricted the access to this video, try with the "--referer" option')
 | 
					                raise ExtractorError(u'The author has restricted the access to this video, try with the "--referer" option')
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -572,6 +572,11 @@ class ExtractorError(Exception):
 | 
				
			|||||||
        return u''.join(traceback.format_tb(self.traceback))
 | 
					        return u''.join(traceback.format_tb(self.traceback))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class RegexNotFoundError(ExtractorError):
 | 
				
			||||||
 | 
					    """Error when a regex didn't match"""
 | 
				
			||||||
 | 
					    pass
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class DownloadError(Exception):
 | 
					class DownloadError(Exception):
 | 
				
			||||||
    """Download Error exception.
 | 
					    """Download Error exception.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user