4 from .common
import InfoExtractor
5 from ..compat
import compat_urllib_parse_unquote_plus
15 class ChingariBaseIE(InfoExtractor
):
16 def _get_post(self
, id, post_data
):
17 media_data
= post_data
['mediaLocation']
18 base_url
= media_data
['base']
19 author_data
= post_data
.get('authorData', {})
20 song_data
= post_data
.get('song', {}) # revist this in future for differentiating b/w 'art' and 'author'
24 'width': str_to_int(frmt
[1:]),
25 'url': base_url
+ frmt_path
,
26 } for frmt
, frmt_path
in media_data
.get('transcoded', {}).items()]
28 if media_data
.get('path'):
30 'format_id': 'original',
31 'format_note': 'Direct video.',
32 'url': base_url
+ '/apipublic' + media_data
['path'],
35 self
._sort
_formats
(formats
)
36 timestamp
= str_to_int(post_data
.get('created_at'))
38 timestamp
= int_or_none(timestamp
, 1000)
40 thumbnail
, uploader_url
= None, None
41 if media_data
.get('thumbnail'):
42 thumbnail
= base_url
+ media_data
.get('thumbnail')
43 if author_data
.get('username'):
44 uploader_url
= 'https://chingari.io/' + author_data
.get('username')
48 'title': compat_urllib_parse_unquote_plus(clean_html(post_data
.get('caption'))),
49 'description': compat_urllib_parse_unquote_plus(clean_html(post_data
.get('caption'))),
50 'duration': media_data
.get('duration'),
51 'thumbnail': url_or_none(thumbnail
),
52 'like_count': post_data
.get('likeCount'),
53 'view_count': post_data
.get('viewsCount'),
54 'comment_count': post_data
.get('commentCount'),
55 'repost_count': post_data
.get('shareCount'),
56 'timestamp': timestamp
,
57 'uploader_id': post_data
.get('userId') or author_data
.get('_id'),
58 'uploader': author_data
.get('name'),
59 'uploader_url': url_or_none(uploader_url
),
60 'track': song_data
.get('title'),
61 'artist': song_data
.get('author'),
66 class ChingariIE(ChingariBaseIE
):
67 _VALID_URL
= r
'https?://(?:www\.)?chingari\.io/share/post\?id=(?P<id>[^&/#?]+)'
69 'url': 'https://chingari.io/share/post?id=612f8f4ce1dc57090e8a7beb',
71 'id': '612f8f4ce1dc57090e8a7beb',
73 'title': 'Happy birthday Srila Prabhupada',
74 'description': 'md5:c7080ebfdfeb06016e638c286d6bc3fa',
76 'thumbnail': 'https://media.chingari.io/uploads/c41d30e2-06b6-4e3b-9b4b-edbb929cec06-1630506826911/thumbnail/198f993f-ce87-4623-82c6-cd071bd6d4f4-1630506828016.jpg',
81 'timestamp': 1630506828,
82 'upload_date': '20210901',
83 'uploader_id': '5f0403982c8bd344f4813f8c',
84 'uploader': 'ISKCON,Inc.',
85 'uploader_url': 'https://chingari.io/iskcon,inc',
89 'params': {'skip_download': True}
92 def _real_extract(self
, url
):
93 id = self
._match
_id
(url
)
94 post_json
= self
._download
_json
(f
'https://api.chingari.io/post/post_details/{id}', id)
95 if post_json
['code'] != 200:
96 raise ExtractorError(post_json
['message'], expected
=True)
97 post_data
= post_json
['data']
98 return self
._get
_post
(id, post_data
)
101 class ChingariUserIE(ChingariBaseIE
):
102 _VALID_URL
= r
'https?://(?:www\.)?chingari\.io/(?!share/post)(?P<id>[^/?]+)'
104 'url': 'https://chingari.io/dada1023',
105 'playlist_mincount': 3,
110 'url': 'https://chingari.io/share/post?id=614781f3ade60b3a0bfff42a',
112 'id': '614781f3ade60b3a0bfff42a',
114 'title': '#chingaribappa ',
115 'description': 'md5:d1df21d84088770468fa63afe3b17857',
117 'thumbnail': 'https://media.chingari.io/uploads/346d86d4-abb2-474e-a164-ffccf2bbcb72-1632076273717/thumbnail/b0b3aac2-2b86-4dd1-909d-9ed6e57cf77c-1632076275552.jpg',
120 'comment_count': int,
122 'timestamp': 1632076275,
123 'upload_date': '20210919',
124 'uploader_id': '5efc4b12cca35c3d1794c2d3',
125 'uploader': 'dada (girish) dhawale',
126 'uploader_url': 'https://chingari.io/dada1023',
130 'params': {'skip_download': True}
132 'url': 'https://chingari.io/share/post?id=6146b132bcbf860959e12cba',
134 'id': '6146b132bcbf860959e12cba',
136 'title': 'Tactor harvesting',
137 'description': 'md5:8403f12dce68828b77ecee7eb7e887b7',
139 'thumbnail': 'https://media.chingari.io/uploads/b353ca70-7a87-400d-93a6-fa561afaec86-1632022814584/thumbnail/c09302e3-2043-41b1-a2fe-77d97e5bd676-1632022834260.jpg',
142 'comment_count': int,
144 'timestamp': 1632022834,
145 'upload_date': '20210919',
146 'uploader_id': '5efc4b12cca35c3d1794c2d3',
147 'uploader': 'dada (girish) dhawale',
148 'uploader_url': 'https://chingari.io/dada1023',
152 'params': {'skip_download': True}
154 'url': 'https://chingari.io/share/post?id=6145651b74cb030a64c40b82',
156 'id': '6145651b74cb030a64c40b82',
158 'title': '#odiabhajan ',
159 'description': 'md5:687ea36835b9276cf2af90f25e7654cb',
161 'thumbnail': 'https://media.chingari.io/uploads/6cbf216b-babc-4cce-87fe-ceaac8d706ac-1631937782708/thumbnail/8855754f-6669-48ce-b269-8cc0699ed6da-1631937819522.jpg',
164 'comment_count': int,
166 'timestamp': 1631937819,
167 'upload_date': '20210918',
168 'uploader_id': '5efc4b12cca35c3d1794c2d3',
169 'uploader': 'dada (girish) dhawale',
170 'uploader_url': 'https://chingari.io/dada1023',
174 'params': {'skip_download': True}
177 'url': 'https://chingari.io/iskcon%2Cinc',
178 'playlist_mincount': 1025,
180 'id': 'iskcon%2Cinc',
184 def _entries(self
, id):
187 for page
in itertools
.count():
188 posts
= self
._download
_json
('https://api.chingari.io/users/getPosts', id,
189 data
=json
.dumps({'userId': id, 'ownerId': id, 'skip': skip, 'limit': 20}
).encode(),
190 headers
={'content-type': 'application/json;charset=UTF-8'}
,
191 note
='Downloading page %s' % page
)
192 for post
in posts
.get('data', []):
193 post_data
= post
['post']
194 yield self
._get
_post
(post_data
['_id'], post_data
)
196 has_more
= posts
['hasMoreData']
200 def _real_extract(self
, url
):
201 alt_id
= self
._match
_id
(url
)
202 post_json
= self
._download
_json
(f
'https://api.chingari.io/user/{alt_id}', alt_id
)
203 if post_json
['code'] != 200:
204 raise ExtractorError(post_json
['message'], expected
=True)
205 id = post_json
['data']['_id']
206 return self
.playlist_result(self
._entries
(id), playlist_id
=alt_id
)