diff options
| -rw-r--r-- | AUTHORS | 1 | ||||
| -rwxr-xr-x | youtube_dl/YoutubeDL.py | 6 | ||||
| -rw-r--r-- | youtube_dl/extractor/generic.py | 24 | ||||
| -rw-r--r-- | youtube_dl/extractor/ivi.py | 27 | ||||
| -rw-r--r-- | youtube_dl/extractor/viddler.py | 63 | 
5 files changed, 93 insertions, 28 deletions
| @@ -106,3 +106,4 @@ Johan K. Jensen  Yen Chi Hsuan  Enam Mijbah Noor  David Luhmer +Shaya Goldberg diff --git a/youtube_dl/YoutubeDL.py b/youtube_dl/YoutubeDL.py index b5dd77e3f..4c238c555 100755 --- a/youtube_dl/YoutubeDL.py +++ b/youtube_dl/YoutubeDL.py @@ -543,6 +543,11 @@ class YoutubeDL(object):              outtmpl = self.params.get('outtmpl', DEFAULT_OUTTMPL)              tmpl = compat_expanduser(outtmpl)              filename = tmpl % template_dict +            # Temporary fix for #4787 +            # 'Treat' all problem characters by passing filename through preferredencoding +            # to workaround encoding issues with subprocess on python2 @ Windows +            if sys.version_info < (3, 0) and sys.platform == 'win32': +                filename = encodeFilename(filename, True).decode(preferredencoding())              return filename          except ValueError as err:              self.report_error('Error in output template: ' + str(err) + ' (encoding: ' + repr(preferredencoding()) + ')') @@ -1069,6 +1074,7 @@ class YoutubeDL(object):                              selected_format = {                                  'requested_formats': formats_info,                                  'format': rf, +                                'format_id': rf,                                  'ext': formats_info[0]['ext'],                                  'width': formats_info[0].get('width'),                                  'height': formats_info[0].get('height'), diff --git a/youtube_dl/extractor/generic.py b/youtube_dl/extractor/generic.py index ad16b8330..41884ed7a 100644 --- a/youtube_dl/extractor/generic.py +++ b/youtube_dl/extractor/generic.py @@ -498,6 +498,19 @@ class GenericIE(InfoExtractor):                  'uploader': 'www.abc.net.au',                  'title': 'Game of Thrones with dice - Dungeons and Dragons fantasy role-playing game gets new life - 19/01/2015',              } +        }, +        # embedded viddler video +        { +            'url': 'http://deadspin.com/i-cant-stop-watching-john-wall-chop-the-nuggets-with-th-1681801597', +            'info_dict': { +                'id': '4d03aad9', +                'ext': 'mp4', +                'uploader': 'deadspin', +                'title': 'WALL-TO-GORTAT', +                'timestamp': 1422285291, +                'upload_date': '20150126', +            }, +            'add_ie': ['Viddler'],          }      ] @@ -860,9 +873,16 @@ class GenericIE(InfoExtractor):          if mobj is not None:              return self.url_result(mobj.group('url')) +        # Look for embedded Viddler player +        mobj = re.search( +            r'<(?:iframe[^>]+?src|param[^>]+?value)=(["\'])(?P<url>(?:https?:)?//(?:www\.)?viddler\.com/(?:embed|player)/.+?)\1', +            webpage) +        if mobj is not None: +            return self.url_result(mobj.group('url')) +          # Look for Ooyala videos -        mobj = (re.search(r'player.ooyala.com/[^"?]+\?[^"]*?(?:embedCode|ec)=(?P<ec>[^"&]+)', webpage) or -                re.search(r'OO.Player.create\([\'"].*?[\'"],\s*[\'"](?P<ec>.{32})[\'"]', webpage)) +        mobj = (re.search(r'player\.ooyala\.com/[^"?]+\?[^"]*?(?:embedCode|ec)=(?P<ec>[^"&]+)', webpage) or +                re.search(r'OO\.Player\.create\([\'"].*?[\'"],\s*[\'"](?P<ec>.{32})[\'"]', webpage))          if mobj is not None:              return OoyalaIE._build_url_result(mobj.group('ec')) diff --git a/youtube_dl/extractor/ivi.py b/youtube_dl/extractor/ivi.py index 7a400323d..e82594444 100644 --- a/youtube_dl/extractor/ivi.py +++ b/youtube_dl/extractor/ivi.py @@ -16,7 +16,7 @@ from ..utils import (  class IviIE(InfoExtractor):      IE_DESC = 'ivi.ru'      IE_NAME = 'ivi' -    _VALID_URL = r'https?://(?:www\.)?ivi\.ru/(?:watch/(?:[^/]+/)?|video/player\?.*?videoId=)(?P<videoid>\d+)' +    _VALID_URL = r'https?://(?:www\.)?ivi\.ru/(?:watch/(?:[^/]+/)?|video/player\?.*?videoId=)(?P<id>\d+)'      _TESTS = [          # Single movie @@ -63,29 +63,34 @@ class IviIE(InfoExtractor):          return int(m.group('commentcount')) if m is not None else 0      def _real_extract(self, url): -        mobj = re.match(self._VALID_URL, url) -        video_id = mobj.group('videoid') +        video_id = self._match_id(url)          api_url = 'http://api.digitalaccess.ru/api/json/' -        data = {'method': 'da.content.get', -                'params': [video_id, {'site': 's183', -                                      'referrer': 'http://www.ivi.ru/watch/%s' % video_id, -                                      'contentid': video_id -                                      } -                           ] +        data = { +            'method': 'da.content.get', +            'params': [ +                video_id, { +                    'site': 's183', +                    'referrer': 'http://www.ivi.ru/watch/%s' % video_id, +                    'contentid': video_id                  } +            ] +        }          request = compat_urllib_request.Request(api_url, json.dumps(data)) -        video_json_page = self._download_webpage(request, video_id, 'Downloading video JSON') +        video_json_page = self._download_webpage( +            request, video_id, 'Downloading video JSON')          video_json = json.loads(video_json_page)          if 'error' in video_json:              error = video_json['error']              if error['origin'] == 'NoRedisValidData':                  raise ExtractorError('Video %s does not exist' % video_id, expected=True) -            raise ExtractorError('Unable to download video %s: %s' % (video_id, error['message']), expected=True) +            raise ExtractorError( +                'Unable to download video %s: %s' % (video_id, error['message']), +                expected=True)          result = video_json['result'] diff --git a/youtube_dl/extractor/viddler.py b/youtube_dl/extractor/viddler.py index 0faa729c6..ef104dc29 100644 --- a/youtube_dl/extractor/viddler.py +++ b/youtube_dl/extractor/viddler.py @@ -5,27 +5,58 @@ from ..utils import (      float_or_none,      int_or_none,  ) +from ..compat import ( +   compat_urllib_request +)  class ViddlerIE(InfoExtractor):      _VALID_URL = r'https?://(?:www\.)?viddler\.com/(?:v|embed|player)/(?P<id>[a-z0-9]+)' -    _TEST = { -        "url": "http://www.viddler.com/v/43903784", +    _TESTS = [{ +        'url': 'http://www.viddler.com/v/43903784',          'md5': 'ae43ad7cb59431ce043f0ff7fa13cbf4',          'info_dict': {              'id': '43903784',              'ext': 'mp4', -            "title": "Video Made Easy", -            'description': 'You don\'t need to be a professional to make high-quality video content. Viddler provides some quick and easy tips on how to produce great video content with limited resources. ', -            "uploader": "viddler", +            'title': 'Video Made Easy', +            'description': 'md5:6a697ebd844ff3093bd2e82c37b409cd', +            'uploader': 'viddler',              'timestamp': 1335371429,              'upload_date': '20120425', -            "duration": 100.89, +            'duration': 100.89,              'thumbnail': 're:^https?://.*\.jpg$',              'view_count': int, +            'comment_count': int,              'categories': ['video content', 'high quality video', 'video made easy', 'how to produce video with limited resources', 'viddler'],          } -    } +    }, { +        'url': 'http://www.viddler.com/v/4d03aad9/', +        'md5': 'faa71fbf70c0bee7ab93076fd007f4b0', +        'info_dict': { +            'id': '4d03aad9', +            'ext': 'mp4', +            'title': 'WALL-TO-GORTAT', +            'upload_date': '20150126', +            'uploader': 'deadspin', +            'timestamp': 1422285291, +            'view_count': int, +            'comment_count': int, +        } +    }, { +        'url': 'http://www.viddler.com/player/221ebbbd/0/', +        'md5': '0defa2bd0ea613d14a6e9bd1db6be326', +        'info_dict': { +            'id': '221ebbbd', +            'ext': 'mp4', +            'title': 'LETeens-Grammar-snack-third-conditional', +            'description': ' ', +            'upload_date': '20140929', +            'uploader': 'BCLETeens', +            'timestamp': 1411997190, +            'view_count': int, +            'comment_count': int, +        } +    }]      def _real_extract(self, url):          video_id = self._match_id(url) @@ -33,14 +64,17 @@ class ViddlerIE(InfoExtractor):          json_url = (              'http://api.viddler.com/api/v2/viddler.videos.getPlaybackDetails.json?video_id=%s&key=v0vhrt7bg2xq1vyxhkct' %              video_id) -        data = self._download_json(json_url, video_id)['video'] +        headers = {'Referer': 'http://static.cdn-ec.viddler.com/js/arpeggio/v2/embed.html'} +        request = compat_urllib_request.Request(json_url, None, headers) +        data = self._download_json(request, video_id)['video']          formats = []          for filed in data['files']:              if filed.get('status', 'ready') != 'ready':                  continue +            format_id = filed.get('profile_id') or filed['profile_name']              f = { -                'format_id': filed['profile_id'], +                'format_id': format_id,                  'format_note': filed['profile_name'],                  'url': self._proto_relative_url(filed['url']),                  'width': int_or_none(filed.get('width')), @@ -53,16 +87,15 @@ class ViddlerIE(InfoExtractor):              if filed.get('cdn_url'):                  f = f.copy() -                f['url'] = self._proto_relative_url(filed['cdn_url']) -                f['format_id'] = filed['profile_id'] + '-cdn' +                f['url'] = self._proto_relative_url(filed['cdn_url'], 'http:') +                f['format_id'] = format_id + '-cdn'                  f['source_preference'] = 1                  formats.append(f)              if filed.get('html5_video_source'):                  f = f.copy() -                f['url'] = self._proto_relative_url( -                    filed['html5_video_source']) -                f['format_id'] = filed['profile_id'] + '-html5' +                f['url'] = self._proto_relative_url(filed['html5_video_source']) +                f['format_id'] = format_id + '-html5'                  f['source_preference'] = 0                  formats.append(f)          self._sort_formats(formats) @@ -71,7 +104,6 @@ class ViddlerIE(InfoExtractor):              t.get('text') for t in data.get('tags', []) if 'text' in t]          return { -            '_type': 'video',              'id': video_id,              'title': data['title'],              'formats': formats, @@ -81,5 +113,6 @@ class ViddlerIE(InfoExtractor):              'uploader': data.get('author'),              'duration': float_or_none(data.get('length')),              'view_count': int_or_none(data.get('view_count')), +            'comment_count': int_or_none(data.get('comment_count')),              'categories': categories,          } | 
