aboutsummaryrefslogtreecommitdiff
path: root/youtube_dl/extractor
diff options
context:
space:
mode:
authorPhilipp Hagemeister <phihag@phihag.de>2014-07-23 01:27:25 +0200
committerPhilipp Hagemeister <phihag@phihag.de>2014-07-23 01:27:25 +0200
commitb090af592277260192689b718721b2192826de23 (patch)
tree1da29454742005d7ac389dc6838ea451dcd8c324 /youtube_dl/extractor
parent388841f8195bd79f242dc5beec8918759903bfae (diff)
[vube] Fix comment count
Diffstat (limited to 'youtube_dl/extractor')
-rw-r--r--youtube_dl/extractor/common.py8
-rw-r--r--youtube_dl/extractor/vube.py30
2 files changed, 29 insertions, 9 deletions
diff --git a/youtube_dl/extractor/common.py b/youtube_dl/extractor/common.py
index 9b36e0789..88f12797c 100644
--- a/youtube_dl/extractor/common.py
+++ b/youtube_dl/extractor/common.py
@@ -301,8 +301,12 @@ class InfoExtractor(object):
def _download_json(self, url_or_request, video_id,
note=u'Downloading JSON metadata',
errnote=u'Unable to download JSON metadata',
- transform_source=None):
- json_string = self._download_webpage(url_or_request, video_id, note, errnote)
+ transform_source=None,
+ fatal=True):
+ json_string = self._download_webpage(
+ url_or_request, video_id, note, errnote, fatal=fatal)
+ if (not fatal) and json_string is False:
+ return None
if transform_source:
json_string = transform_source(json_string)
try:
diff --git a/youtube_dl/extractor/vube.py b/youtube_dl/extractor/vube.py
index c1ab76465..f1b9e9a19 100644
--- a/youtube_dl/extractor/vube.py
+++ b/youtube_dl/extractor/vube.py
@@ -25,7 +25,10 @@ class VubeIE(InfoExtractor):
'uploader': 'Chiara.Grispo',
'timestamp': 1388743358,
'upload_date': '20140103',
- 'duration': 170.56
+ 'duration': 170.56,
+ 'like_count': int,
+ 'dislike_count': int,
+ 'comment_count': int,
}
},
{
@@ -40,7 +43,10 @@ class VubeIE(InfoExtractor):
'uploader': 'Seraina',
'timestamp': 1396492438,
'upload_date': '20140403',
- 'duration': 240.107
+ 'duration': 240.107,
+ 'like_count': int,
+ 'dislike_count': int,
+ 'comment_count': int,
}
}, {
'url': 'http://vube.com/vote/Siren+Gene/0nmsMY5vEq?n=2&t=s',
@@ -56,6 +62,7 @@ class VubeIE(InfoExtractor):
'duration': 221.788,
'like_count': int,
'dislike_count': int,
+ 'comment_count': int,
}
}
]
@@ -70,7 +77,6 @@ class VubeIE(InfoExtractor):
webpage, 'video data'
)
data = json.loads(data_json)
- open('/dev/shm/f', 'w').write(json.dumps(data, indent=2))
video = (
data.get('video') or
data)
@@ -101,12 +107,22 @@ class VubeIE(InfoExtractor):
duration = video['duration']
view_count = video.get('raw_view_count')
like_count = video.get('rlikes')
+ if like_count is None:
+ like_count = video.get('total_likes')
dislike_count = video.get('rhates')
+ if dislike_count is None:
+ dislike_count = video.get('total_hates')
- comment = self._download_json(
- 'http://vube.com/api/video/%s/comment' % video_id, video_id, 'Downloading video comment JSON')
-
- comment_count = int_or_none(comment.get('total'))
+ comments = video.get('comments')
+ comment_count = None
+ if comments is None:
+ comment_data = self._download_json(
+ 'http://vube.com/api/video/%s/comment' % video_id,
+ video_id, 'Downloading video comment JSON', fatal=False)
+ if comment_data is not None:
+ comment_count = int_or_none(comment_data.get('total'))
+ else:
+ comment_count = len(comments)
return {
'id': video_id,