]> jfr.im git - yt-dlp.git/blame - yt_dlp/extractor/patreon.py
[cleanup] Add more ruff rules (#10149)
[yt-dlp.git] / yt_dlp / extractor / patreon.py
CommitLineData
1dd6d9ca 1import itertools
c9ce57d9 2import urllib.parse
1dd6d9ca 3
a00d73c8 4from .common import InfoExtractor
65af1839 5from .vimeo import VimeoIE
3d2623a8 6from ..networking.exceptions import HTTPError
c9d891f1 7from ..utils import (
11de6fec 8 KNOWN_EXTENSIONS,
9 ExtractorError,
c9d891f1
RA
10 clean_html,
11 determine_ext,
12 int_or_none,
b77c3949 13 mimetype2ext,
c9d891f1 14 parse_iso8601,
b77c3949 15 str_or_none,
4f08e586 16 traverse_obj,
1dd6d9ca 17 url_or_none,
11de6fec 18 urljoin,
c9d891f1 19)
a00d73c8
EJ
20
21
4f08e586 22class PatreonBaseIE(InfoExtractor):
23 USER_AGENT = 'Patreon/7.6.28 (Android; Android 11; Scale/2.10)'
24
25 def _call_api(self, ep, item_id, query=None, headers=None, fatal=True, note=None):
26 if headers is None:
27 headers = {}
28 if 'User-Agent' not in headers:
29 headers['User-Agent'] = self.USER_AGENT
30 if query:
31 query.update({'json-api-version': 1.0})
32
33 try:
34 return self._download_json(
35 f'https://www.patreon.com/api/{ep}',
add96eb9 36 item_id, note=note if note else 'Downloading API JSON',
4f08e586 37 query=query, fatal=fatal, headers=headers)
38 except ExtractorError as e:
3d2623a8 39 if not isinstance(e.cause, HTTPError) or mimetype2ext(e.cause.response.headers.get('Content-Type')) != 'json':
4f08e586 40 raise
3d2623a8 41 err_json = self._parse_json(self._webpage_read_content(e.cause.response, None, item_id), item_id, fatal=False)
4f08e586 42 err_message = traverse_obj(err_json, ('errors', ..., 'detail'), get_all=False)
43 if err_message:
44 raise ExtractorError(f'Patreon said: {err_message}', expected=True)
45 raise
46
47
48class PatreonIE(PatreonBaseIE):
c9d891f1
RA
49 _VALID_URL = r'https?://(?:www\.)?patreon\.com/(?:creation\?hid=|posts/(?:[\w-]+-)?)(?P<id>\d+)'
50 _TESTS = [{
51 'url': 'http://www.patreon.com/creation?hid=743933',
52 'md5': 'e25505eec1053a6e6813b8ed369875cc',
53 'info_dict': {
54 'id': '743933',
55 'ext': 'mp3',
56 'title': 'Episode 166: David Smalley of Dogma Debate',
4f08e586 57 'description': 'md5:34d207dd29aa90e24f1b3f58841b81c7',
c9d891f1
RA
58 'uploader': 'Cognitive Dissonance Podcast',
59 'thumbnail': 're:^https?://.*$',
60 'timestamp': 1406473987,
61 'upload_date': '20140727',
b77c3949 62 'uploader_id': '87145',
4f08e586 63 'like_count': int,
64 'comment_count': int,
65 'uploader_url': 'https://www.patreon.com/dissonancepod',
66 'channel_id': '80642',
67 'channel_url': 'https://www.patreon.com/dissonancepod',
68 'channel_follower_count': int,
c9d891f1
RA
69 },
70 }, {
71 'url': 'http://www.patreon.com/creation?hid=754133',
72 'md5': '3eb09345bf44bf60451b8b0b81759d0a',
73 'info_dict': {
74 'id': '754133',
75 'ext': 'mp3',
76 'title': 'CD 167 Extra',
77 'uploader': 'Cognitive Dissonance Podcast',
78 'thumbnail': 're:^https?://.*$',
4f08e586 79 'like_count': int,
80 'comment_count': int,
81 'uploader_url': 'https://www.patreon.com/dissonancepod',
a00d73c8 82 },
c9d891f1
RA
83 'skip': 'Patron-only content',
84 }, {
85 'url': 'https://www.patreon.com/creation?hid=1682498',
86 'info_dict': {
87 'id': 'SU4fj_aEMVw',
88 'ext': 'mp4',
89 'title': 'I\'m on Patreon!',
90 'uploader': 'TraciJHines',
91 'thumbnail': 're:^https?://.*$',
92 'upload_date': '20150211',
4f08e586 93 'description': 'md5:8af6425f50bd46fbf29f3db0fc3a8364',
36b240f9 94 'uploader_id': '@TraciHinesMusic',
4f08e586 95 'categories': ['Entertainment'],
96 'duration': 282,
97 'view_count': int,
98 'tags': 'count:39',
99 'age_limit': 0,
100 'channel': 'TraciJHines',
101 'channel_url': 'https://www.youtube.com/channel/UCGLim4T2loE5rwCMdpCIPVg',
102 'live_status': 'not_live',
103 'like_count': int,
104 'channel_id': 'UCGLim4T2loE5rwCMdpCIPVg',
105 'availability': 'public',
106 'channel_follower_count': int,
107 'playable_in_embed': True,
36b240f9 108 'uploader_url': 'https://www.youtube.com/@TraciHinesMusic',
4f08e586 109 'comment_count': int,
36b240f9
JV
110 'channel_is_verified': True,
111 'chapters': 'count:4',
6994e706 112 },
c9d891f1
RA
113 'params': {
114 'noplaylist': True,
115 'skip_download': True,
add96eb9 116 },
c9d891f1
RA
117 }, {
118 'url': 'https://www.patreon.com/posts/episode-166-of-743933',
119 'only_matching': True,
120 }, {
121 'url': 'https://www.patreon.com/posts/743933',
122 'only_matching': True,
65af1839 123 }, {
124 'url': 'https://www.patreon.com/posts/kitchen-as-seen-51706779',
125 'md5': '96656690071f6d64895866008484251b',
126 'info_dict': {
127 'id': '555089736',
128 'ext': 'mp4',
129 'title': 'KITCHEN AS SEEN ON DEEZ NUTS EXTENDED!',
130 'uploader': 'Cold Ones',
131 'thumbnail': 're:^https?://.*$',
132 'upload_date': '20210526',
133 'description': 'md5:557a409bd79d3898689419094934ba79',
134 'uploader_id': '14936315',
135 },
add96eb9 136 'skip': 'Patron-only content',
4f08e586 137 }, {
138 # m3u8 video (https://github.com/yt-dlp/yt-dlp/issues/2277)
139 'url': 'https://www.patreon.com/posts/video-sketchbook-32452882',
140 'info_dict': {
141 'id': '32452882',
142 'ext': 'mp4',
143 'comment_count': int,
144 'uploader_id': '4301314',
145 'like_count': int,
146 'timestamp': 1576696962,
147 'upload_date': '20191218',
148 'thumbnail': r're:^https?://.*$',
149 'uploader_url': 'https://www.patreon.com/loish',
150 'description': 'md5:e2693e97ee299c8ece47ffdb67e7d9d2',
151 'title': 'VIDEO // sketchbook flipthrough',
152 'uploader': 'Loish ',
153 'tags': ['sketchbook', 'video'],
154 'channel_id': '1641751',
155 'channel_url': 'https://www.patreon.com/loish',
156 'channel_follower_count': int,
add96eb9 157 },
cea4b857 158 }, {
159 # bad videos under media (if media is included). Real one is under post_file
160 'url': 'https://www.patreon.com/posts/premium-access-70282931',
161 'info_dict': {
162 'id': '70282931',
163 'ext': 'mp4',
164 'title': '[Premium Access + Uncut] The Office - 2x6 The Fight - Group Reaction',
165 'channel_url': 'https://www.patreon.com/thenormies',
166 'channel_id': '573397',
167 'uploader_id': '2929435',
168 'uploader': 'The Normies',
169 'description': 'md5:79c9fd8778e2cef84049a94c058a5e23',
170 'comment_count': int,
171 'upload_date': '20220809',
172 'thumbnail': r're:^https?://.*$',
173 'channel_follower_count': int,
174 'like_count': int,
175 'timestamp': 1660052820,
176 'tags': ['The Office', 'early access', 'uncut'],
177 'uploader_url': 'https://www.patreon.com/thenormies',
178 },
179 'skip': 'Patron-only content',
36b240f9
JV
180 }, {
181 # dead vimeo and embed URLs, need to extract post_file
182 'url': 'https://www.patreon.com/posts/hunter-x-hunter-34007913',
183 'info_dict': {
184 'id': '34007913',
185 'ext': 'mp4',
186 'title': 'Hunter x Hunter | Kurapika DESTROYS Uvogin!!!',
187 'like_count': int,
188 'uploader': 'YaBoyRoshi',
189 'timestamp': 1581636833,
190 'channel_url': 'https://www.patreon.com/yaboyroshi',
191 'thumbnail': r're:^https?://.*$',
192 'tags': ['Hunter x Hunter'],
193 'uploader_id': '14264111',
194 'comment_count': int,
195 'channel_follower_count': int,
196 'description': 'Kurapika is a walking cheat code!',
197 'upload_date': '20200213',
198 'channel_id': '2147162',
199 'uploader_url': 'https://www.patreon.com/yaboyroshi',
200 },
c9ce57d9 201 }, {
202 # NSFW vimeo embed URL
203 'url': 'https://www.patreon.com/posts/4k-spiderman-4k-96414599',
204 'info_dict': {
205 'id': '902250943',
206 'ext': 'mp4',
207 'title': '❤️(4K) Spiderman Girl Yeonhwa’s Gift ❤️(4K) 스파이더맨걸 연화의 선물',
208 'description': '❤️(4K) Spiderman Girl Yeonhwa’s Gift \n❤️(4K) 스파이더맨걸 연화의 선물',
209 'uploader': 'Npickyeonhwa',
210 'uploader_id': '90574422',
211 'uploader_url': 'https://www.patreon.com/Yeonhwa726',
212 'channel_id': '10237902',
213 'channel_url': 'https://www.patreon.com/Yeonhwa726',
214 'duration': 70,
215 'timestamp': 1705150153,
216 'upload_date': '20240113',
217 'comment_count': int,
218 'like_count': int,
219 'thumbnail': r're:^https?://.+',
220 },
221 'params': {'skip_download': 'm3u8'},
036e0d92 222 }, {
223 # multiple attachments/embeds
224 'url': 'https://www.patreon.com/posts/holy-wars-solos-100601977',
225 'playlist_count': 3,
226 'info_dict': {
227 'id': '100601977',
228 'title': '"Holy Wars" (Megadeth) Solos Transcription & Lesson/Analysis',
229 'description': 'md5:d099ab976edfce6de2a65c2b169a88d3',
230 'uploader': 'Bradley Hall',
231 'uploader_id': '24401883',
232 'uploader_url': 'https://www.patreon.com/bradleyhallguitar',
233 'channel_id': '3193932',
234 'channel_url': 'https://www.patreon.com/bradleyhallguitar',
235 'channel_follower_count': int,
236 'timestamp': 1710777855,
237 'upload_date': '20240318',
238 'like_count': int,
239 'comment_count': int,
240 'thumbnail': r're:^https?://.+',
241 },
242 'skip': 'Patron-only content',
4f08e586 243 }]
036e0d92 244 _RETURN_TYPE = 'video'
a00d73c8
EJ
245
246 def _real_extract(self, url):
77070040 247 video_id = self._match_id(url)
4f08e586 248 post = self._call_api(
249 f'posts/{video_id}', video_id, query={
b77c3949 250 'fields[media]': 'download_url,mimetype,size_bytes',
4f08e586 251 'fields[post]': 'comment_count,content,embed,image,like_count,post_file,published_at,title,current_user_can_view',
b77c3949 252 'fields[user]': 'full_name,url',
4f08e586 253 'fields[post_tag]': 'value',
254 'fields[campaign]': 'url,name,patron_count',
b77c3949 255 'json-api-use-default-includes': 'false',
cea4b857 256 'include': 'audio,user,user_defined_tags,campaign,attachments_media',
b77c3949 257 })
c9d891f1 258 attributes = post['data']['attributes']
036e0d92 259 info = traverse_obj(attributes, {
260 'title': ('title', {str.strip}),
261 'description': ('content', {clean_html}),
262 'thumbnail': ('image', ('large_url', 'url'), {url_or_none}, any),
263 'timestamp': ('published_at', {parse_iso8601}),
264 'like_count': ('like_count', {int_or_none}),
265 'comment_count': ('comment_count', {int_or_none}),
266 })
c9d891f1 267
036e0d92 268 entries = []
269 idx = 0
270 for include in traverse_obj(post, ('included', lambda _, v: v['type'])):
271 include_type = include['type']
272 if include_type == 'media':
273 media_attributes = traverse_obj(include, ('attributes', {dict})) or {}
274 download_url = url_or_none(media_attributes.get('download_url'))
b77c3949 275 ext = mimetype2ext(media_attributes.get('mimetype'))
cea4b857 276
277 # if size_bytes is None, this media file is likely unavailable
278 # See: https://github.com/yt-dlp/yt-dlp/issues/4608
279 size_bytes = int_or_none(media_attributes.get('size_bytes'))
280 if download_url and ext in KNOWN_EXTENSIONS and size_bytes is not None:
036e0d92 281 idx += 1
282 entries.append({
283 'id': f'{video_id}-{idx}',
b77c3949 284 'ext': ext,
cea4b857 285 'filesize': size_bytes,
b77c3949 286 'url': download_url,
c9d891f1
RA
287 })
288
036e0d92 289 elif include_type == 'user':
290 info.update(traverse_obj(include, {
291 'uploader': ('attributes', 'full_name', {str}),
292 'uploader_id': ('id', {str_or_none}),
293 'uploader_url': ('attributes', 'url', {url_or_none}),
294 }))
65af1839 295
036e0d92 296 elif include_type == 'post_tag':
297 if post_tag := traverse_obj(include, ('attributes', 'value', {str})):
298 info.setdefault('tags', []).append(post_tag)
299
300 elif include_type == 'campaign':
301 info.update(traverse_obj(include, {
302 'channel': ('attributes', 'title', {str}),
303 'channel_id': ('id', {str_or_none}),
304 'channel_url': ('attributes', 'url', {url_or_none}),
305 'channel_follower_count': ('attributes', 'patron_count', {int_or_none}),
306 }))
19a35285 307
4f08e586 308 # handle Vimeo embeds
c9ce57d9 309 if traverse_obj(attributes, ('embed', 'provider')) == 'Vimeo':
310 v_url = urllib.parse.unquote(self._html_search_regex(
311 r'(https(?:%3A%2F%2F|://)player\.vimeo\.com.+app_id(?:=|%3D)+\d+)',
312 traverse_obj(attributes, ('embed', 'html', {str})), 'vimeo url', fatal=False) or '')
313 if url_or_none(v_url) and self._request_webpage(
314 v_url, video_id, 'Checking Vimeo embed URL',
315 headers={'Referer': 'https://patreon.com/'},
316 fatal=False, errnote=False):
036e0d92 317 entries.append(self.url_result(
c9ce57d9 318 VimeoIE._smuggle_referrer(v_url, 'https://patreon.com/'),
036e0d92 319 VimeoIE, url_transparent=True))
4f08e586 320
c9ce57d9 321 embed_url = traverse_obj(attributes, ('embed', 'url', {url_or_none}))
36b240f9 322 if embed_url and self._request_webpage(embed_url, video_id, 'Checking embed URL', fatal=False, errnote=False):
036e0d92 323 entries.append(self.url_result(embed_url))
4f08e586 324
036e0d92 325 post_file = traverse_obj(attributes, ('post_file', {dict}))
4f08e586 326 if post_file:
327 name = post_file.get('name')
328 ext = determine_ext(name)
b77c3949 329 if ext in KNOWN_EXTENSIONS:
036e0d92 330 entries.append({
331 'id': video_id,
b77c3949
RA
332 'ext': ext,
333 'url': post_file['url'],
036e0d92 334 })
f0e8bc7c 335 elif name == 'video' or determine_ext(post_file.get('url')) == 'm3u8':
4f08e586 336 formats, subtitles = self._extract_m3u8_formats_and_subtitles(post_file['url'], video_id)
036e0d92 337 entries.append({
338 'id': video_id,
4f08e586 339 'formats': formats,
340 'subtitles': subtitles,
036e0d92 341 })
c9d891f1 342
036e0d92 343 can_view_post = traverse_obj(attributes, 'current_user_can_view')
344 comments = None
345 if can_view_post and info.get('comment_count'):
346 comments = self.extract_comments(video_id)
347
348 if not entries and can_view_post is False:
4f08e586 349 self.raise_no_formats('You do not have access to this post', video_id=video_id, expected=True)
036e0d92 350 elif not entries:
4f08e586 351 self.raise_no_formats('No supported media found in this post', video_id=video_id, expected=True)
036e0d92 352 elif len(entries) == 1:
353 info.update(entries[0])
354 else:
355 for entry in entries:
356 entry.update(info)
357 return self.playlist_result(entries, video_id, **info, __post_extractor=comments)
358
359 info['id'] = video_id
360 info['__post_extractor'] = comments
c9d891f1 361 return info
1dd6d9ca 362
4f08e586 363 def _get_comments(self, post_id):
364 cursor = None
365 count = 0
366 params = {
367 'page[count]': 50,
368 'include': 'parent.commenter.campaign,parent.post.user,parent.post.campaign.creator,parent.replies.parent,parent.replies.commenter.campaign,parent.replies.post.user,parent.replies.post.campaign.creator,commenter.campaign,post.user,post.campaign.creator,replies.parent,replies.commenter.campaign,replies.post.user,replies.post.campaign.creator,on_behalf_of_campaign',
369 'fields[comment]': 'body,created,is_by_creator',
370 'fields[user]': 'image_url,full_name,url',
371 'filter[flair]': 'image_tiny_url,name',
372 'sort': '-created',
373 'json-api-version': 1.0,
374 'json-api-use-default-includes': 'false',
375 }
376
377 for page in itertools.count(1):
378
379 params.update({'page[cursor]': cursor} if cursor else {})
380 response = self._call_api(
add96eb9 381 f'posts/{post_id}/comments', post_id, query=params, note=f'Downloading comments page {page}')
4f08e586 382
383 cursor = None
6839ae1f 384 for comment in traverse_obj(response, (('data', ('included', lambda _, v: v['type'] == 'comment')), ...)):
4f08e586 385 count += 1
386 comment_id = comment.get('id')
387 attributes = comment.get('attributes') or {}
388 if comment_id is None:
389 continue
390 author_id = traverse_obj(comment, ('relationships', 'commenter', 'data', 'id'))
391 author_info = traverse_obj(
392 response, ('included', lambda _, v: v['id'] == author_id and v['type'] == 'user', 'attributes'),
393 get_all=False, expected_type=dict, default={})
394
395 yield {
396 'id': comment_id,
397 'text': attributes.get('body'),
398 'timestamp': parse_iso8601(attributes.get('created')),
399 'parent': traverse_obj(comment, ('relationships', 'parent', 'data', 'id'), default='root'),
400 'author_is_uploader': attributes.get('is_by_creator'),
401 'author_id': author_id,
402 'author': author_info.get('full_name'),
403 'author_thumbnail': author_info.get('image_url'),
404 }
405
406 if count < traverse_obj(response, ('meta', 'count')):
407 cursor = traverse_obj(response, ('data', -1, 'id'))
408
409 if cursor is None:
410 break
1dd6d9ca 411
1dd6d9ca 412
4f08e586 413class PatreonCampaignIE(PatreonBaseIE):
1dd6d9ca 414
4f08e586 415 _VALID_URL = r'https?://(?:www\.)?patreon\.com/(?!rss)(?:(?:m/(?P<campaign_id>\d+))|(?P<vanity>[-\w]+))'
1dd6d9ca 416 _TESTS = [{
417 'url': 'https://www.patreon.com/dissonancepod/',
418 'info_dict': {
4f08e586 419 'title': 'Cognitive Dissonance Podcast',
420 'channel_url': 'https://www.patreon.com/dissonancepod',
421 'id': '80642',
422 'description': 'md5:eb2fa8b83da7ab887adeac34da6b7af7',
423 'channel_id': '80642',
424 'channel': 'Cognitive Dissonance Podcast',
425 'age_limit': 0,
426 'channel_follower_count': int,
427 'uploader_id': '87145',
428 'uploader_url': 'https://www.patreon.com/dissonancepod',
429 'uploader': 'Cognitive Dissonance Podcast',
430 'thumbnail': r're:^https?://.*$',
1dd6d9ca 431 },
432 'playlist_mincount': 68,
4f08e586 433 }, {
434 'url': 'https://www.patreon.com/m/4767637/posts',
435 'info_dict': {
436 'title': 'Not Just Bikes',
437 'channel_follower_count': int,
438 'id': '4767637',
439 'channel_id': '4767637',
440 'channel_url': 'https://www.patreon.com/notjustbikes',
441 'description': 'md5:595c6e7dca76ae615b1d38c298a287a1',
442 'age_limit': 0,
443 'channel': 'Not Just Bikes',
444 'uploader_url': 'https://www.patreon.com/notjustbikes',
445 'uploader': 'Not Just Bikes',
446 'uploader_id': '37306634',
447 'thumbnail': r're:^https?://.*$',
448 },
add96eb9 449 'playlist_mincount': 71,
1dd6d9ca 450 }, {
451 'url': 'https://www.patreon.com/dissonancepod/posts',
add96eb9 452 'only_matching': True,
4f08e586 453 }, {
454 'url': 'https://www.patreon.com/m/5932659',
add96eb9 455 'only_matching': True,
4f08e586 456 }]
1dd6d9ca 457
458 @classmethod
459 def suitable(cls, url):
add96eb9 460 return False if PatreonIE.suitable(url) else super().suitable(url)
1dd6d9ca 461
4f08e586 462 def _entries(self, campaign_id):
1dd6d9ca 463 cursor = None
464 params = {
4f08e586 465 'fields[post]': 'patreon_url,url',
1dd6d9ca 466 'filter[campaign_id]': campaign_id,
467 'filter[is_draft]': 'false',
468 'sort': '-published_at',
1dd6d9ca 469 'json-api-use-default-includes': 'false',
470 }
471
472 for page in itertools.count(1):
473
474 params.update({'page[cursor]': cursor} if cursor else {})
add96eb9 475 posts_json = self._call_api('posts', campaign_id, query=params, note=f'Downloading posts page {page}')
1dd6d9ca 476
4f08e586 477 cursor = traverse_obj(posts_json, ('meta', 'pagination', 'cursors', 'next'))
11de6fec 478 for post_url in traverse_obj(posts_json, ('data', ..., 'attributes', 'patreon_url')):
479 yield self.url_result(urljoin('https://www.patreon.com/', post_url), PatreonIE)
1dd6d9ca 480
481 if cursor is None:
482 break
483
484 def _real_extract(self, url):
485
4f08e586 486 campaign_id, vanity = self._match_valid_url(url).group('campaign_id', 'vanity')
487 if campaign_id is None:
488 webpage = self._download_webpage(url, vanity, headers={'User-Agent': self.USER_AGENT})
2e5a47da 489 campaign_id = self._search_nextjs_data(
490 webpage, vanity)['props']['pageProps']['bootstrapEnvelope']['pageBootstrap']['campaign']['data']['id']
4f08e586 491
492 params = {
493 'json-api-use-default-includes': 'false',
494 'fields[user]': 'full_name,url',
495 'fields[campaign]': 'name,summary,url,patron_count,creation_count,is_nsfw,avatar_photo_url',
add96eb9 496 'include': 'creator',
4f08e586 497 }
498
499 campaign_response = self._call_api(
500 f'campaigns/{campaign_id}', campaign_id,
501 note='Downloading campaign info', fatal=False,
502 query=params) or {}
503
504 campaign_info = campaign_response.get('data') or {}
505 channel_name = traverse_obj(campaign_info, ('attributes', 'name'))
506 user_info = traverse_obj(
507 campaign_response, ('included', lambda _, v: v['type'] == 'user'),
508 default={}, expected_type=dict, get_all=False)
509
510 return {
511 '_type': 'playlist',
512 'id': campaign_id,
513 'title': channel_name,
514 'entries': self._entries(campaign_id),
515 'description': clean_html(traverse_obj(campaign_info, ('attributes', 'summary'))),
516 'channel_url': traverse_obj(campaign_info, ('attributes', 'url')),
517 'channel_follower_count': int_or_none(traverse_obj(campaign_info, ('attributes', 'patron_count'))),
518 'channel_id': campaign_id,
519 'channel': channel_name,
520 'uploader_url': traverse_obj(user_info, ('attributes', 'url')),
521 'uploader_id': str_or_none(user_info.get('id')),
522 'uploader': traverse_obj(user_info, ('attributes', 'full_name')),
523 'playlist_count': traverse_obj(campaign_info, ('attributes', 'creation_count')),
524 'age_limit': 18 if traverse_obj(campaign_info, ('attributes', 'is_nsfw')) else 0,
525 'thumbnail': url_or_none(traverse_obj(campaign_info, ('attributes', 'avatar_photo_url'))),
526 }