]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/flipagram.py
   2 from __future__ 
import unicode_literals
 
   4 from .common 
import InfoExtractor
 
   5 from ..compat 
import compat_str
 
  14 class FlipagramIE(InfoExtractor
): 
  15     _VALID_URL 
= r
'https?://(?:www\.)?flipagram\.com/f/(?P<id>[^/?#&]+)' 
  17         'url': 'https://flipagram.com/f/nyvTSJMKId', 
  18         'md5': '888dcf08b7ea671381f00fab74692755', 
  22             'title': 'Flipagram by sjuria101 featuring Midnight Memories by One Direction', 
  23             'description': 'md5:d55e32edc55261cae96a41fa85ff630e', 
  25             'timestamp': 1461244995, 
  26             'upload_date': '20160421', 
  27             'uploader': 'kitty juria', 
  28             'uploader_id': 'sjuria101', 
  29             'creator': 'kitty juria', 
  35             'formats': 'mincount:2', 
  39     def _real_extract(self
, url
): 
  40         video_id 
= self
._match
_id
(url
) 
  41         webpage 
= self
._download
_webpage
(url
, video_id
) 
  43         video_data 
= self
._parse
_json
( 
  45                 r
'window\.reactH2O\s*=\s*({.+});', webpage
, 'video data'), 
  48         flipagram 
= video_data
['flipagram'] 
  49         video 
= flipagram
['video'] 
  51         json_ld 
= self
._search
_json
_ld
(webpage
, video_id
, default
={}) 
  52         title 
= json_ld
.get('title') or flipagram
['captionText'] 
  53         description 
= json_ld
.get('description') or flipagram
.get('captionText') 
  57             'width': int_or_none(video
.get('width')), 
  58             'height': int_or_none(video
.get('height')), 
  59             'filesize': int_or_none(video_data
.get('size')), 
  62         preview_url 
= try_get( 
  63             flipagram
, lambda x
: x
['music']['track']['previewUrl'], compat_str
) 
  71         self
._sort
_formats
(formats
) 
  73         counts 
= flipagram
.get('counts', {}) 
  74         user 
= flipagram
.get('user', {}) 
  75         video_data 
= flipagram
.get('video', {}) 
  78             'url': self
._proto
_relative
_url
(cover
['url']), 
  79             'width': int_or_none(cover
.get('width')), 
  80             'height': int_or_none(cover
.get('height')), 
  81             'filesize': int_or_none(cover
.get('size')), 
  82         } for cover 
in flipagram
.get('covers', []) if cover
.get('url')] 
  84         # Note that this only retrieves comments that are initially loaded. 
  85         # For videos with large amounts of comments, most won't be retrieved. 
  87         for comment 
in video_data
.get('comments', {}).get(video_id
, {}).get('items', []): 
  88             text 
= comment
.get('comment') 
  89             if not text 
or not isinstance(text
, list): 
  92                 'author': comment
.get('user', {}).get('name'), 
  93                 'author_id': comment
.get('user', {}).get('username'), 
  94                 'id': comment
.get('id'), 
  96                 'timestamp': unified_timestamp(comment
.get('created')), 
 102             'description': description
, 
 103             'duration': float_or_none(flipagram
.get('duration'), 1000), 
 104             'thumbnails': thumbnails
, 
 105             'timestamp': unified_timestamp(flipagram
.get('iso8601Created')), 
 106             'uploader': user
.get('name'), 
 107             'uploader_id': user
.get('username'), 
 108             'creator': user
.get('name'), 
 109             'view_count': int_or_none(counts
.get('plays')), 
 110             'like_count': int_or_none(counts
.get('likes')), 
 111             'repost_count': int_or_none(counts
.get('reflips')), 
 112             'comment_count': int_or_none(counts
.get('comments')), 
 113             'comments': comments
,