Skip to content

Commit

Permalink
[picarto] Extract more metadata (closes #16518)
Browse files Browse the repository at this point in the history
  • Loading branch information
dstftw committed Nov 11, 2018
1 parent f17a24a commit 730c0d1
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions youtube_dl/extractor/picarto.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
# coding: utf-8
from __future__ import unicode_literals

import re
import time

from .common import InfoExtractor
from ..compat import compat_str
from ..utils import (
ExtractorError,
js_to_json,
try_get,
update_url_query,
urlencode_postdata,
)
Expand All @@ -32,7 +34,9 @@ def suitable(cls, url):
return False if PicartoVodIE.suitable(url) else super(PicartoIE, cls).suitable(url)

def _real_extract(self, url):
channel_id = self._match_id(url)
mobj = re.match(self._VALID_URL, url)
channel_id = mobj.group('id')

metadata = self._download_json(
'https://api.picarto.tv/v1/channel/name/' + channel_id,
channel_id)
Expand All @@ -45,7 +49,7 @@ def _real_extract(self, url):
data=urlencode_postdata({'loadbalancinginfo': channel_id}),
note='Downloading load balancing info')

token = self._VALID_URL_RE.match(url).group('token') or 'public'
token = mobj.group('token') or 'public'
params = {
'con': int(time.time() * 1000),
'token': token,
Expand Down Expand Up @@ -99,9 +103,11 @@ def _real_extract(self, url):

return {
'id': channel_id,
'title': self._live_title(channel_id),
'title': self._live_title(metadata.get('title') or channel_id),
'is_live': True,
'thumbnail': metadata.get('thumbnails', {}).get('web'),
'thumbnail': try_get(metadata, lambda x: x['thumbnails']['web']),
'channel': channel_id,
'channel_url': 'https://picarto.tv/%s' % channel_id,
'age_limit': age_limit,
'formats': formats,
}
Expand Down

0 comments on commit 730c0d1

Please sign in to comment.