1 from .common
import InfoExtractor
11 class MindsBaseIE(InfoExtractor
):
12 _VALID_URL_BASE
= r
'https?://(?:www\.)?minds\.com/'
14 def _call_api(self
, path
, video_id
, resource
, query
=None):
15 api_url
= 'https://www.minds.com/api/' + path
16 token
= self
._get
_cookies
(api_url
).get('XSRF-TOKEN')
17 return self
._download
_json
(
18 api_url
, video_id
, f
'Downloading {resource} JSON metadata', headers
={
19 'Referer': 'https://www.minds.com/',
20 'X-XSRF-TOKEN': token
.value
if token
else '',
24 class MindsIE(MindsBaseIE
):
26 _VALID_URL
= MindsBaseIE
._VALID
_URL
_BASE
+ r
'(?:media|newsfeed|archive/view)/(?P<id>[0-9]+)'
28 'url': 'https://www.minds.com/media/100000000000086822',
29 'md5': '215a658184a419764852239d4970b045',
31 'id': '100000000000086822',
33 'title': 'Minds intro sequence',
34 'thumbnail': r
're:https?://.+\.png',
35 'uploader_id': 'ottman',
36 'upload_date': '20130524',
37 'timestamp': 1369404826,
38 'uploader': 'Bill Ottman',
42 'tags': ['animation'],
44 'license': 'attribution-cc',
47 # entity.type == 'activity' and empty title
48 'url': 'https://www.minds.com/newsfeed/798025111988506624',
49 'md5': 'b2733a74af78d7fd3f541c4cbbaa5950',
51 'id': '798022190320226304',
53 'title': '798022190320226304',
54 'uploader': 'ColinFlaherty',
55 'upload_date': '20180111',
56 'timestamp': 1515639316,
57 'uploader_id': 'ColinFlaherty',
60 'url': 'https://www.minds.com/archive/view/715172106794442752',
61 'only_matching': True,
64 'url': 'https://www.minds.com/newsfeed/1197131838022602752',
65 'only_matching': True,
68 def _real_extract(self
, url
):
69 entity_id
= self
._match
_id
(url
)
70 entity
= self
._call
_api
(
71 'v1/entities/entity/' + entity_id
, entity_id
, 'entity')['entity']
72 if entity
.get('type') == 'activity':
73 if entity
.get('custom_type') == 'video':
74 video_id
= entity
['entity_guid']
76 return self
.url_result(entity
['perma_url'])
78 assert entity
['subtype'] == 'video'
80 # 1080p and webm formats available only on the sources array
81 video
= self
._call
_api
(
82 'v2/media/video/' + video_id
, video_id
, 'video')
85 for source
in (video
.get('sources') or []):
86 src
= source
.get('src')
90 'format_id': source
.get('label'),
91 'height': int_or_none(source
.get('size')),
95 entity
= video
.get('entity') or entity
96 owner
= entity
.get('ownerObj') or {}
97 uploader_id
= owner
.get('username')
99 tags
= entity
.get('tags')
100 if tags
and isinstance(tags
, str):
104 poster
= video
.get('poster') or entity
.get('thumbnail_src')
106 urlh
= self
._request
_webpage
(poster
, video_id
, fatal
=False)
112 'title': entity
.get('title') or video_id
,
114 'description': clean_html(entity
.get('description')) or None,
115 'license': str_or_none(entity
.get('license')),
116 'timestamp': int_or_none(entity
.get('time_created')),
117 'uploader': strip_or_none(owner
.get('name')),
118 'uploader_id': uploader_id
,
119 'uploader_url': format_field(uploader_id
, None, 'https://www.minds.com/%s'),
120 'view_count': int_or_none(entity
.get('play:count')),
121 'like_count': int_or_none(entity
.get('thumbs:up:count')),
122 'dislike_count': int_or_none(entity
.get('thumbs:down:count')),
124 'comment_count': int_or_none(entity
.get('comments:count')),
125 'thumbnail': thumbnail
,
129 class MindsFeedBaseIE(MindsBaseIE
):
132 def _entries(self
, feed_id
):
133 query
= {'limit': self
._PAGE
_SIZE
, 'sync': 1}
136 data
= self
._call
_api
(
137 f
'v2/feeds/container/{feed_id}/videos',
138 feed_id
, f
'page {i}', query
)
139 entities
= data
.get('entities') or []
140 for entity
in entities
:
141 guid
= entity
.get('guid')
144 yield self
.url_result(
145 'https://www.minds.com/newsfeed/' + guid
,
146 MindsIE
.ie_key(), guid
)
147 query
['from_timestamp'] = data
['load-next']
148 if not (query
['from_timestamp'] and len(entities
) == self
._PAGE
_SIZE
):
152 def _real_extract(self
, url
):
153 feed_id
= self
._match
_id
(url
)
154 feed
= self
._call
_api
(
155 f
'v1/{self._FEED_PATH}/{feed_id}',
156 feed_id
, self
._FEED
_TYPE
)[self
._FEED
_TYPE
]
158 return self
.playlist_result(
159 self
._entries
(feed
['guid']), feed_id
,
160 strip_or_none(feed
.get('name')),
161 feed
.get('briefdescription'))
164 class MindsChannelIE(MindsFeedBaseIE
):
165 _FEED_TYPE
= 'channel'
166 IE_NAME
= 'minds:' + _FEED_TYPE
167 _VALID_URL
= MindsBaseIE
._VALID
_URL
_BASE
+ r
'(?!(?:newsfeed|media|api|archive|groups)/)(?P<id>[^/?&#]+)'
168 _FEED_PATH
= 'channel'
170 'url': 'https://www.minds.com/ottman',
173 'title': 'Bill Ottman',
174 'description': 'Co-creator & CEO @minds',
176 'playlist_mincount': 54,
180 class MindsGroupIE(MindsFeedBaseIE
):
182 IE_NAME
= 'minds:' + _FEED_TYPE
183 _VALID_URL
= MindsBaseIE
._VALID
_URL
_BASE
+ r
'groups/profile/(?P<id>[0-9]+)'
184 _FEED_PATH
= 'groups/group'
186 'url': 'https://www.minds.com/groups/profile/785582576369672204/feed/videos',
188 'id': '785582576369672204',
189 'title': 'Cooking Videos',
191 'playlist_mincount': 1,