File tree Expand file tree Collapse file tree 1 file changed +6
-4
lines changed
pod/activitypub/deserialization Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change 1010
1111def format_ap_video_data (payload , source_instance ):
1212 """Create an ExternalVideo object from an AP Video payload."""
13-
1413 video_source_links = [
1514 {
1615 "type" : link ["mediaType" ],
@@ -39,14 +38,17 @@ def format_ap_video_data(payload, source_instance):
3938 if "mediaType" in link and link ["mediaType" ] == "video/mp4"
4039 ]
4140
41+ # For peertube payloads, guess the thumbnail by looking for 'thumbnail' in the url
42+ thumbnails = [
43+ icon for icon in payload ["icon" ] if "thumbnails" in icon ["url" ]
44+ ] + payload ["icon" ]
45+ thumbnail_url = thumbnails [0 ]["url" ] if thumbnails else None
4246 external_video_attributes = {
4347 "ap_id" : payload ["id" ],
4448 "videos" : video_source_links ,
4549 "title" : payload ["name" ],
4650 "date_added" : isoparse (payload ["published" ]),
47- "thumbnail" : [icon for icon in payload ["icon" ] if "thumbnails" in icon ["url" ]][
48- 0
49- ]["url" ],
51+ "thumbnail" : thumbnail_url ,
5052 "duration" : int (payload ["duration" ].lstrip ("PT" ).rstrip ("S" )),
5153 "viewcount" : payload ["views" ],
5254 "source_instance" : source_instance ,
You can’t perform that action at this time.
0 commit comments