X-Git-Url: http://git.cielonegro.org/gitweb.cgi?a=blobdiff_plain;f=youtube_dl%2Fextractor%2Fcamdemy.py;h=897f3a104ce2d31aeac99e98197557ef502faf18;hb=c73cdd800f0dc7b465ac0b36d338875bb80c23aa;hp=1bc602c31e8407c4e0931203e92b416cc802d267;hpb=024c53694d674f046fdad593e03bfaeec17cc559;p=youtube-dl.git diff --git a/youtube_dl/extractor/camdemy.py b/youtube_dl/extractor/camdemy.py index 1bc602c31..897f3a104 100644 --- a/youtube_dl/extractor/camdemy.py +++ b/youtube_dl/extractor/camdemy.py @@ -1,15 +1,22 @@ # coding: utf-8 from __future__ import unicode_literals +import datetime import re from .common import InfoExtractor -from ..compat import (compat_urllib_parse, compat_urlparse) -from ..utils import parse_iso8601 +from ..compat import ( + compat_urllib_parse, + compat_urlparse, +) +from ..utils import ( + parse_iso8601, + str_to_int, +) class CamdemyIE(InfoExtractor): - _VALID_URL = r'http://www.camdemy.com/media/(?P\d+)' + _VALID_URL = r'http://(?:www\.)?camdemy\.com/media/(?P\d+)' _TESTS = [{ # single file 'url': 'http://www.camdemy.com/media/5181/', @@ -23,6 +30,7 @@ class CamdemyIE(InfoExtractor): 'creator': 'ss11spring', 'upload_date': '20130114', 'timestamp': 1358154556, + 'view_count': int, } }, { # With non-empty description @@ -55,46 +63,43 @@ class CamdemyIE(InfoExtractor): def _real_extract(self, url): video_id = self._match_id(url) - page = self._download_webpage(url, video_id) - srcFrom = self._html_search_regex( + src_from = self._html_search_regex( r"
Source: Posted :
[\r\n ]*
([^<>]+)<", - page, 'creation time', flags=re.MULTILINE) + '+08:00' - creation_timestamp = parse_iso8601(creation_time, delimiter=' ') + file_name = file_list_doc.find('./video/item/fileName').text + video_url = compat_urlparse.urljoin(video_folder, file_name) - view_count_str = self._html_search_regex( - r"
Views :
[\r\n ]*
([^<>]+)<", - page, 'view count', flags=re.MULTILINE) - views = int(view_count_str.replace(',', '')) + timestamp = parse_iso8601(self._html_search_regex( + r"
Posted\s*:
\s*
([^<>]+)<", + page, 'creation time', fatal=False), + delimiter=' ', timezone=datetime.timedelta(hours=8)) + view_count = str_to_int(self._html_search_regex( + r"
Views\s*:
\s*
([^<>]+)<", + page, 'view count', fatal=False)) return { 'id': video_id, - 'url': compat_urlparse.urljoin(video_folder, fileName), + 'url': video_url, 'title': oembed_obj['title'], 'thumbnail': thumb_url, 'description': self._html_search_meta('description', page), 'creator': oembed_obj['author_name'], 'duration': oembed_obj['duration'], - 'timestamp': creation_timestamp, - 'view_count': views, + 'timestamp': timestamp, + 'view_count': view_count, }