Compare commits
	
		
			5 Commits
		
	
	
		
			2014.08.24
			...
			2014.08.24
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						 | 
					e673db0194 | ||
| 
						 | 
					ebab4520ff | ||
| 
						 | 
					a71d1414eb | ||
| 
						 | 
					423817c468 | ||
| 
						 | 
					51ed9fce09 | 
@@ -88,6 +88,7 @@ from .engadget import EngadgetIE
 | 
			
		||||
from .escapist import EscapistIE
 | 
			
		||||
from .everyonesmixtape import EveryonesMixtapeIE
 | 
			
		||||
from .exfm import ExfmIE
 | 
			
		||||
from .expotv import ExpoTVIE
 | 
			
		||||
from .extremetube import ExtremeTubeIE
 | 
			
		||||
from .facebook import FacebookIE
 | 
			
		||||
from .faz import FazIE
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										73
									
								
								youtube_dl/extractor/expotv.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										73
									
								
								youtube_dl/extractor/expotv.py
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,73 @@
 | 
			
		||||
from __future__ import unicode_literals
 | 
			
		||||
 | 
			
		||||
import re
 | 
			
		||||
 | 
			
		||||
from .common import InfoExtractor
 | 
			
		||||
from ..utils import (
 | 
			
		||||
    int_or_none,
 | 
			
		||||
    unified_strdate,
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class ExpoTVIE(InfoExtractor):
 | 
			
		||||
    _VALID_URL = r'https?://www\.expotv\.com/videos/[^?#]*/(?P<id>[0-9]+)($|[?#])'
 | 
			
		||||
    _TEST = {
 | 
			
		||||
        'url': 'http://www.expotv.com/videos/reviews/1/24/LinneCardscom/17561',
 | 
			
		||||
        'md5': '2985e6d7a392b2f7a05e0ca350fe41d0',
 | 
			
		||||
        'info_dict': {
 | 
			
		||||
            'id': '17561',
 | 
			
		||||
            'ext': 'mp4',
 | 
			
		||||
            'upload_date': '20060212',
 | 
			
		||||
            'title': 'My Favorite Online Scrapbook Store',
 | 
			
		||||
            'view_count': int,
 | 
			
		||||
            'description': 'You\'ll find most everything you need at this virtual store front.',
 | 
			
		||||
            'uploader': 'Anna T.',
 | 
			
		||||
            'thumbnail': 're:^https?://.*\.jpg$',
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    def _real_extract(self, url):
 | 
			
		||||
        mobj = re.match(self._VALID_URL, url)
 | 
			
		||||
        video_id = mobj.group('id')
 | 
			
		||||
 | 
			
		||||
        webpage = self._download_webpage(url, video_id)
 | 
			
		||||
        player_key = self._search_regex(
 | 
			
		||||
            r'<param name="playerKey" value="([^"]+)"', webpage, 'player key')
 | 
			
		||||
        config_url = 'http://client.expotv.com/video/config/%s/%s' % (
 | 
			
		||||
            video_id, player_key)
 | 
			
		||||
        config = self._download_json(
 | 
			
		||||
            config_url, video_id,
 | 
			
		||||
            note='Downloading video configuration')
 | 
			
		||||
 | 
			
		||||
        formats = [{
 | 
			
		||||
            'url': fcfg['file'],
 | 
			
		||||
            'height': int_or_none(fcfg.get('height')),
 | 
			
		||||
            'format_note': fcfg.get('label'),
 | 
			
		||||
            'ext': self._search_regex(
 | 
			
		||||
                r'filename=.*\.([a-z0-9_A-Z]+)&', fcfg['file'],
 | 
			
		||||
                'file extension', default=None),
 | 
			
		||||
        } for fcfg in config['sources']]
 | 
			
		||||
        self._sort_formats(formats)
 | 
			
		||||
 | 
			
		||||
        title = self._og_search_title(webpage)
 | 
			
		||||
        description = self._og_search_description(webpage)
 | 
			
		||||
        thumbnail = config.get('image')
 | 
			
		||||
        view_count = int_or_none(self._search_regex(
 | 
			
		||||
            r'<h5>Plays: ([0-9]+)</h5>', webpage, 'view counts'))
 | 
			
		||||
        uploader = self._search_regex(
 | 
			
		||||
            r'<div class="reviewer">\s*<img alt="([^"]+)"', webpage, 'uploader',
 | 
			
		||||
            fatal=False)
 | 
			
		||||
        upload_date = unified_strdate(self._search_regex(
 | 
			
		||||
            r'<h5>Reviewed on ([0-9/.]+)</h5>', webpage, 'upload date',
 | 
			
		||||
            fatal=False))
 | 
			
		||||
 | 
			
		||||
        return {
 | 
			
		||||
            'id': video_id,
 | 
			
		||||
            'formats': formats,
 | 
			
		||||
            'title': title,
 | 
			
		||||
            'description': description,
 | 
			
		||||
            'view_count': view_count,
 | 
			
		||||
            'thumbnail': thumbnail,
 | 
			
		||||
            'uploader': uploader,
 | 
			
		||||
            'upload_date': upload_date,
 | 
			
		||||
        }
 | 
			
		||||
@@ -356,58 +356,6 @@ class GenericIE(InfoExtractor):
 | 
			
		||||
        """Report information extraction."""
 | 
			
		||||
        self._downloader.to_screen('[redirect] Following redirect to %s' % new_url)
 | 
			
		||||
 | 
			
		||||
    def _send_head(self, url):
 | 
			
		||||
        """Check if it is a redirect, like url shorteners, in case return the new url."""
 | 
			
		||||
 | 
			
		||||
        class HEADRedirectHandler(compat_urllib_request.HTTPRedirectHandler):
 | 
			
		||||
            """
 | 
			
		||||
            Subclass the HTTPRedirectHandler to make it use our
 | 
			
		||||
            HEADRequest also on the redirected URL
 | 
			
		||||
            """
 | 
			
		||||
            def redirect_request(self, req, fp, code, msg, headers, newurl):
 | 
			
		||||
                if code in (301, 302, 303, 307):
 | 
			
		||||
                    newurl = newurl.replace(' ', '%20')
 | 
			
		||||
                    newheaders = dict((k,v) for k,v in req.headers.items()
 | 
			
		||||
                                      if k.lower() not in ("content-length", "content-type"))
 | 
			
		||||
                    try:
 | 
			
		||||
                        # This function was deprecated in python 3.3 and removed in 3.4
 | 
			
		||||
                        origin_req_host = req.get_origin_req_host()
 | 
			
		||||
                    except AttributeError:
 | 
			
		||||
                        origin_req_host = req.origin_req_host
 | 
			
		||||
                    return HEADRequest(newurl,
 | 
			
		||||
                                       headers=newheaders,
 | 
			
		||||
                                       origin_req_host=origin_req_host,
 | 
			
		||||
                                       unverifiable=True)
 | 
			
		||||
                else:
 | 
			
		||||
                    raise compat_urllib_error.HTTPError(req.get_full_url(), code, msg, headers, fp)
 | 
			
		||||
 | 
			
		||||
        class HTTPMethodFallback(compat_urllib_request.BaseHandler):
 | 
			
		||||
            """
 | 
			
		||||
            Fallback to GET if HEAD is not allowed (405 HTTP error)
 | 
			
		||||
            """
 | 
			
		||||
            def http_error_405(self, req, fp, code, msg, headers):
 | 
			
		||||
                fp.read()
 | 
			
		||||
                fp.close()
 | 
			
		||||
 | 
			
		||||
                newheaders = dict((k,v) for k,v in req.headers.items()
 | 
			
		||||
                                  if k.lower() not in ("content-length", "content-type"))
 | 
			
		||||
                return self.parent.open(compat_urllib_request.Request(req.get_full_url(),
 | 
			
		||||
                                                 headers=newheaders,
 | 
			
		||||
                                                 origin_req_host=req.get_origin_req_host(),
 | 
			
		||||
                                                 unverifiable=True))
 | 
			
		||||
 | 
			
		||||
        # Build our opener
 | 
			
		||||
        opener = compat_urllib_request.OpenerDirector()
 | 
			
		||||
        for handler in [compat_urllib_request.HTTPHandler, compat_urllib_request.HTTPDefaultErrorHandler,
 | 
			
		||||
                        HTTPMethodFallback, HEADRedirectHandler,
 | 
			
		||||
                        compat_urllib_request.HTTPErrorProcessor, compat_urllib_request.HTTPSHandler]:
 | 
			
		||||
            opener.add_handler(handler())
 | 
			
		||||
 | 
			
		||||
        response = opener.open(HEADRequest(url))
 | 
			
		||||
        if response is None:
 | 
			
		||||
            raise ExtractorError('Invalid URL protocol')
 | 
			
		||||
        return response
 | 
			
		||||
 | 
			
		||||
    def _extract_rss(self, url, video_id, doc):
 | 
			
		||||
        playlist_title = doc.find('./channel/title').text
 | 
			
		||||
        playlist_desc_el = doc.find('./channel/description')
 | 
			
		||||
@@ -511,9 +459,13 @@ class GenericIE(InfoExtractor):
 | 
			
		||||
 | 
			
		||||
        self.to_screen('%s: Requesting header' % video_id)
 | 
			
		||||
 | 
			
		||||
        try:
 | 
			
		||||
            response = self._send_head(url)
 | 
			
		||||
        head_req = HEADRequest(url)
 | 
			
		||||
        response = self._request_webpage(
 | 
			
		||||
            head_req, video_id,
 | 
			
		||||
            note=False, errnote='Could not send HEAD request to %s' % url,
 | 
			
		||||
            fatal=False)
 | 
			
		||||
 | 
			
		||||
        if response is not False:
 | 
			
		||||
            # Check for redirect
 | 
			
		||||
            new_url = response.geturl()
 | 
			
		||||
            if url != new_url:
 | 
			
		||||
@@ -541,10 +493,6 @@ class GenericIE(InfoExtractor):
 | 
			
		||||
                    'upload_date': upload_date,
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
        except compat_urllib_error.HTTPError:
 | 
			
		||||
            # This may be a stupid server that doesn't like HEAD, our UA, or so
 | 
			
		||||
            pass
 | 
			
		||||
 | 
			
		||||
        try:
 | 
			
		||||
            webpage = self._download_webpage(url, video_id)
 | 
			
		||||
        except ValueError:
 | 
			
		||||
 
 | 
			
		||||
@@ -1,3 +1,5 @@
 | 
			
		||||
from __future__ import unicode_literals
 | 
			
		||||
 | 
			
		||||
import re
 | 
			
		||||
 | 
			
		||||
from .common import InfoExtractor
 | 
			
		||||
@@ -9,15 +11,16 @@ from ..utils import (
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class PornotubeIE(InfoExtractor):
 | 
			
		||||
    _VALID_URL = r'^(?:https?://)?(?:\w+\.)?pornotube\.com(/c/(?P<channel>[0-9]+))?(/m/(?P<videoid>[0-9]+))(/(?P<title>.+))$'
 | 
			
		||||
    _VALID_URL = r'https?://(?:\w+\.)?pornotube\.com(/c/(?P<channel>[0-9]+))?(/m/(?P<videoid>[0-9]+))(/(?P<title>.+))$'
 | 
			
		||||
    _TEST = {
 | 
			
		||||
        u'url': u'http://pornotube.com/c/173/m/1689755/Marilyn-Monroe-Bathing',
 | 
			
		||||
        u'file': u'1689755.flv',
 | 
			
		||||
        u'md5': u'374dd6dcedd24234453b295209aa69b6',
 | 
			
		||||
        u'info_dict': {
 | 
			
		||||
            u"upload_date": u"20090708", 
 | 
			
		||||
            u"title": u"Marilyn-Monroe-Bathing",
 | 
			
		||||
            u"age_limit": 18
 | 
			
		||||
        'url': 'http://pornotube.com/c/173/m/1689755/Marilyn-Monroe-Bathing',
 | 
			
		||||
        'md5': '374dd6dcedd24234453b295209aa69b6',
 | 
			
		||||
        'info_dict': {
 | 
			
		||||
            'id': '1689755',
 | 
			
		||||
            'ext': 'flv',
 | 
			
		||||
            'upload_date': '20090708',
 | 
			
		||||
            'title': 'Marilyn-Monroe-Bathing',
 | 
			
		||||
            'age_limit': 18
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -32,22 +35,22 @@ class PornotubeIE(InfoExtractor):
 | 
			
		||||
 | 
			
		||||
        # Get the video URL
 | 
			
		||||
        VIDEO_URL_RE = r'url: "(?P<url>http://video[0-9].pornotube.com/.+\.flv)",'
 | 
			
		||||
        video_url = self._search_regex(VIDEO_URL_RE, webpage, u'video url')
 | 
			
		||||
        video_url = self._search_regex(VIDEO_URL_RE, webpage, 'video url')
 | 
			
		||||
        video_url = compat_urllib_parse.unquote(video_url)
 | 
			
		||||
 | 
			
		||||
        #Get the uploaded date
 | 
			
		||||
        VIDEO_UPLOADED_RE = r'<div class="video_added_by">Added (?P<date>[0-9\/]+) by'
 | 
			
		||||
        upload_date = self._html_search_regex(VIDEO_UPLOADED_RE, webpage, u'upload date', fatal=False)
 | 
			
		||||
        if upload_date: upload_date = unified_strdate(upload_date)
 | 
			
		||||
        upload_date = self._html_search_regex(VIDEO_UPLOADED_RE, webpage, 'upload date', fatal=False)
 | 
			
		||||
        if upload_date:
 | 
			
		||||
            upload_date = unified_strdate(upload_date)
 | 
			
		||||
        age_limit = self._rta_search(webpage)
 | 
			
		||||
 | 
			
		||||
        info = {'id': video_id,
 | 
			
		||||
                'url': video_url,
 | 
			
		||||
                'uploader': None,
 | 
			
		||||
                'upload_date': upload_date,
 | 
			
		||||
                'title': video_title,
 | 
			
		||||
                'ext': 'flv',
 | 
			
		||||
                'format': 'flv',
 | 
			
		||||
                'age_limit': age_limit}
 | 
			
		||||
 | 
			
		||||
        return [info]
 | 
			
		||||
        return {
 | 
			
		||||
            'id': video_id,
 | 
			
		||||
            'url': video_url,
 | 
			
		||||
            'upload_date': upload_date,
 | 
			
		||||
            'title': video_title,
 | 
			
		||||
            'ext': 'flv',
 | 
			
		||||
            'format': 'flv',
 | 
			
		||||
            'age_limit': age_limit,
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
@@ -855,6 +855,7 @@ def unified_strdate(date_str):
 | 
			
		||||
        '%Y/%m/%d',
 | 
			
		||||
        '%d.%m.%Y',
 | 
			
		||||
        '%d/%m/%Y',
 | 
			
		||||
        '%d/%m/%y',
 | 
			
		||||
        '%Y/%m/%d %H:%M:%S',
 | 
			
		||||
        '%Y-%m-%d %H:%M:%S',
 | 
			
		||||
        '%d.%m.%Y %H:%M',
 | 
			
		||||
 
 | 
			
		||||
@@ -1,2 +1,2 @@
 | 
			
		||||
 | 
			
		||||
__version__ = '2014.08.24.3'
 | 
			
		||||
__version__ = '2014.08.24.5'
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user