1 from .common
import InfoExtractor
2 from ..utils
import float_or_none
, int_or_none
, url_or_none
3 from ..utils
.traversal
import traverse_obj
6 class SnapchatSpotlightIE(InfoExtractor
):
7 _VALID_URL
= r
'https?://(?:www\.)?snapchat\.com/spotlight/(?P<id>\w+)'
10 'url': 'https://www.snapchat.com/spotlight/W7_EDlXWTBiXAEEniNoMPwAAYYWtidGhudGZpAX1TKn0JAX1TKnXJAAAAAA',
11 'md5': '46c580f63592d0cbb76e974d2f9f0fcc',
13 'id': 'W7_EDlXWTBiXAEEniNoMPwAAYYWtidGhudGZpAX1TKn0JAX1TKnXJAAAAAA',
17 'thumbnail': r
're:https://cf-st\.sc-cdn\.net/d/kKJHIR1QAznRKK9jgYYDq\.256\.IRZXSOY',
19 'timestamp': 1637777831.369,
20 'upload_date': '20211124',
22 'uploader': 'shreypatel57',
23 'uploader_url': 'https://www.snapchat.com/add/shreypatel57',
26 'url': 'https://www.snapchat.com/spotlight/W7_EDlXWTBiXAEEniNoMPwAAYcnVjYWdwcGV1AZEaIYn5AZEaIYnrAAAAAQ',
27 'md5': '4cd9626458c1a0e3e6dbe72c544a9ec2',
29 'id': 'W7_EDlXWTBiXAEEniNoMPwAAYcnVjYWdwcGV1AZEaIYn5AZEaIYnrAAAAAQ',
31 'title': 'Spotlight Snap',
32 'description': 'How he flirt her teacher🤭🤭🤩😍 #kdrama#cdrama #dramaclips #dramaspotlight',
33 'thumbnail': r
're:https://cf-st\.sc-cdn\.net/i/ztfr6xFs0FOcFhwVczWfj\.256\.IRZXSOY',
35 'timestamp': 1722720291.307,
36 'upload_date': '20240803',
39 'uploader': 'ganda0535',
40 'uploader_url': 'https://www.snapchat.com/add/ganda0535',
41 'tags': ['#dramaspotlight', '#dramaclips', '#cdrama', '#kdrama'],
45 def _real_extract(self
, url
):
46 video_id
= self
._match
_id
(url
)
47 webpage
= self
._download
_webpage
(url
, video_id
)
48 page_props
= self
._search
_nextjs
_data
(webpage
, video_id
)['props']['pageProps']
49 video_data
= traverse_obj(page_props
, (
50 'spotlightFeed', 'spotlightStories',
51 lambda _
, v
: v
['story']['storyId']['value'] == video_id
, 'metadata', any
), None)
56 **traverse_obj(video_data
, ('videoMetadata', {
57 'title': ('name', {str}
),
58 'description': ('description', {str}
),
59 'timestamp': ('uploadDateMs', {lambda x
: float_or_none(x
, 1000)}),
60 'view_count': ('viewCount', {int_or_none}
, {lambda x
: None if x
== -1 else x
}),
61 'repost_count': ('shareCount', {int_or_none}
),
62 'url': ('contentUrl', {url_or_none}
),
63 'width': ('width', {int_or_none}
),
64 'height': ('height', {int_or_none}
),
65 'duration': ('durationMs', {lambda x
: float_or_none(x
, 1000)}),
66 'thumbnail': ('thumbnailUrl', {url_or_none}
),
67 'uploader': ('creator', 'personCreator', 'username', {str}
),
68 'uploader_url': ('creator', 'personCreator', 'url', {url_or_none}
),
70 **traverse_obj(video_data
, {
71 'description': ('description', {str}
),
72 'tags': ('hashtags', ..., {str}
),
73 'view_count': ('engagementStats', 'viewCount', {int_or_none}
, {lambda x
: None if x
== -1 else x
}),
74 'repost_count': ('engagementStats', 'shareCount', {int_or_none}
),