]>
jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/playfm.py
2 from __future__
import unicode_literals
5 from .common
import InfoExtractor
6 from ..compat
import compat_str
14 class PlayFMIE(InfoExtractor
):
16 _VALID_URL
= r
'https?://(?:www\.)?play\.fm/(?P<slug>(?:[^/]+/)+(?P<id>[^/]+))/?(?:$|[?#])'
19 'url': 'https://www.play.fm/dan-drastic/sven-tasnadi-leipzig-electronic-music-batofar-paris-fr-2014-07-12',
20 'md5': 'c505f8307825a245d0c7ad1850001f22',
24 'title': 'Sven Tasnadi - LEIPZIG ELECTRONIC MUSIC @ Batofar (Paris,FR) - 2014-07-12',
27 'timestamp': 1406033781,
28 'upload_date': '20140722',
29 'uploader': 'Dan Drastic',
30 'uploader_id': '71170',
36 def _real_extract(self
, url
):
37 mobj
= self
._match
_valid
_url
(url
)
38 video_id
= mobj
.group('id')
39 slug
= mobj
.group('slug')
41 recordings
= self
._download
_json
(
42 'http://v2api.play.fm/recordings/slug/%s' % slug
, video_id
)
44 error
= recordings
.get('error')
45 if isinstance(error
, dict):
47 '%s returned error: %s' % (self
.IE_NAME
, error
.get('message')),
50 audio_url
= recordings
['audio']
51 video_id
= compat_str(recordings
.get('id') or video_id
)
52 title
= recordings
['title']
53 description
= recordings
.get('description')
54 duration
= int_or_none(recordings
.get('recordingDuration'))
55 timestamp
= parse_iso8601(recordings
.get('created_at'))
56 uploader
= recordings
.get('page', {}).get('title')
57 uploader_id
= compat_str(recordings
.get('page', {}).get('id'))
58 view_count
= int_or_none(recordings
.get('playCount'))
59 comment_count
= int_or_none(recordings
.get('commentCount'))
60 categories
= [tag
['name'] for tag
in recordings
.get('tags', []) if tag
.get('name')]
66 'description': description
,
68 'timestamp': timestamp
,
70 'uploader_id': uploader_id
,
71 'view_count': view_count
,
72 'comment_count': comment_count
,
73 'categories': categories
,