Move XVideos IE into its own file (and simplify it a bit)
This commit is contained in:
		
							parent
							
								
									7beb36a529
								
							
						
					
					
						commit
						cbf46c737c
					
				
					 2 changed files with 44 additions and 43 deletions
				
			
		| 
						 | 
				
			
			@ -37,54 +37,12 @@ from .extractor.statigram import StatigramIE
 | 
			
		|||
from .extractor.photobucket import PhotobucketIE
 | 
			
		||||
from .extractor.soundcloud import SoundcloudIE, SoundcloudSetIE
 | 
			
		||||
from .extractor.vimeo import VimeoIE
 | 
			
		||||
from .extractor.xvideos import XVideosIE
 | 
			
		||||
from .extractor.yahoo import YahooIE, YahooSearchIE
 | 
			
		||||
from .extractor.youtube import YoutubeIE, YoutubePlaylistIE, YoutubeSearchIE, YoutubeUserIE, YoutubeChannelIE
 | 
			
		||||
from .extractor.zdf import ZDFIE
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class XVideosIE(InfoExtractor):
 | 
			
		||||
    """Information extractor for xvideos.com"""
 | 
			
		||||
 | 
			
		||||
    _VALID_URL = r'^(?:https?://)?(?:www\.)?xvideos\.com/video([0-9]+)(?:.*)'
 | 
			
		||||
    IE_NAME = u'xvideos'
 | 
			
		||||
 | 
			
		||||
    def _real_extract(self, url):
 | 
			
		||||
        mobj = re.match(self._VALID_URL, url)
 | 
			
		||||
        if mobj is None:
 | 
			
		||||
            raise ExtractorError(u'Invalid URL: %s' % url)
 | 
			
		||||
        video_id = mobj.group(1)
 | 
			
		||||
 | 
			
		||||
        webpage = self._download_webpage(url, video_id)
 | 
			
		||||
 | 
			
		||||
        self.report_extraction(video_id)
 | 
			
		||||
 | 
			
		||||
        # Extract video URL
 | 
			
		||||
        video_url = compat_urllib_parse.unquote(self._search_regex(r'flv_url=(.+?)&',
 | 
			
		||||
            webpage, u'video URL'))
 | 
			
		||||
 | 
			
		||||
        # Extract title
 | 
			
		||||
        video_title = self._html_search_regex(r'<title>(.*?)\s+-\s+XVID',
 | 
			
		||||
            webpage, u'title')
 | 
			
		||||
 | 
			
		||||
        # Extract video thumbnail
 | 
			
		||||
        video_thumbnail = self._search_regex(r'http://(?:img.*?\.)xvideos.com/videos/thumbs/[a-fA-F0-9]+/[a-fA-F0-9]+/[a-fA-F0-9]+/[a-fA-F0-9]+/([a-fA-F0-9.]+jpg)',
 | 
			
		||||
            webpage, u'thumbnail', fatal=False)
 | 
			
		||||
 | 
			
		||||
        info = {
 | 
			
		||||
            'id': video_id,
 | 
			
		||||
            'url': video_url,
 | 
			
		||||
            'uploader': None,
 | 
			
		||||
            'upload_date': None,
 | 
			
		||||
            'title': video_title,
 | 
			
		||||
            'ext': 'flv',
 | 
			
		||||
            'thumbnail': video_thumbnail,
 | 
			
		||||
            'description': None,
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return [info]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class InfoQIE(InfoExtractor):
 | 
			
		||||
    """Information extractor for infoq.com"""
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										43
									
								
								youtube_dl/extractor/xvideos.py
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										43
									
								
								youtube_dl/extractor/xvideos.py
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,43 @@
 | 
			
		|||
import re
 | 
			
		||||
 | 
			
		||||
from .common import InfoExtractor
 | 
			
		||||
from ..utils import (
 | 
			
		||||
    compat_urllib_parse,
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class XVideosIE(InfoExtractor):
 | 
			
		||||
    _VALID_URL = r'^(?:https?://)?(?:www\.)?xvideos\.com/video([0-9]+)(?:.*)'
 | 
			
		||||
 | 
			
		||||
    def _real_extract(self, url):
 | 
			
		||||
        mobj = re.match(self._VALID_URL, url)
 | 
			
		||||
        video_id = mobj.group(1)
 | 
			
		||||
 | 
			
		||||
        webpage = self._download_webpage(url, video_id)
 | 
			
		||||
 | 
			
		||||
        self.report_extraction(video_id)
 | 
			
		||||
 | 
			
		||||
        # Extract video URL
 | 
			
		||||
        video_url = compat_urllib_parse.unquote(self._search_regex(r'flv_url=(.+?)&',
 | 
			
		||||
            webpage, u'video URL'))
 | 
			
		||||
 | 
			
		||||
        # Extract title
 | 
			
		||||
        video_title = self._html_search_regex(r'<title>(.*?)\s+-\s+XVID',
 | 
			
		||||
            webpage, u'title')
 | 
			
		||||
 | 
			
		||||
        # Extract video thumbnail
 | 
			
		||||
        video_thumbnail = self._search_regex(r'http://(?:img.*?\.)xvideos.com/videos/thumbs/[a-fA-F0-9]+/[a-fA-F0-9]+/[a-fA-F0-9]+/[a-fA-F0-9]+/([a-fA-F0-9.]+jpg)',
 | 
			
		||||
            webpage, u'thumbnail', fatal=False)
 | 
			
		||||
 | 
			
		||||
        info = {
 | 
			
		||||
            'id': video_id,
 | 
			
		||||
            'url': video_url,
 | 
			
		||||
            'uploader': None,
 | 
			
		||||
            'upload_date': None,
 | 
			
		||||
            'title': video_title,
 | 
			
		||||
            'ext': 'flv',
 | 
			
		||||
            'thumbnail': video_thumbnail,
 | 
			
		||||
            'description': None,
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return [info]
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue