File tree Expand file tree Collapse file tree
packages/platforms/src/platforms Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -9,12 +9,19 @@ const FOLLOWUP_RE =
99
1010async function parseMedia ( raw : Record < string , any > ) : Promise < NormalizedPost [ "media" ] > {
1111 if ( raw . video ) {
12- const videoURL = raw . video . PlayAddrStruct . UrlList [ 2 ] ;
13- const video = await fetch ( videoURL , {
14- method : "GET" ,
15- redirect : "follow" ,
16- } ) ;
17- return [ { url : video . url , type : "video" } ] ;
12+ const urls = raw . video . PlayAddrStruct ?. UrlList ?? [ ] ;
13+ for ( const url of urls ) {
14+ const video = await fetch ( url , {
15+ method : "GET" ,
16+ redirect : "follow" ,
17+ headers : {
18+ Range : "bytes=0-0" ,
19+ } ,
20+ } ) ;
21+ await video . body ?. cancel ( ) ;
22+ if ( ! video . ok || ! video . headers . get ( "Content-Type" ) ?. startsWith ( "video/" ) ) continue ;
23+ return [ { url, type : "video" } ] ;
24+ }
1825 }
1926 return [ ] ;
2027}
You can’t perform that action at this time.
0 commit comments