From 3e8c059a3ab722834fbad53aba18acbb6744c6a8 Mon Sep 17 00:00:00 2001 From: wukko Date: Sat, 2 Dec 2023 21:52:38 +0600 Subject: [PATCH] vimeo: fix parsing and resolution in filename - all videos/audios should now be downloadable - proper resolution is now displayed in basic and pretty filename styles --- src/modules/processing/matchActionDecider.js | 4 -- src/modules/processing/services/vimeo.js | 50 +++++++------------- src/modules/stream/types.js | 9 +++- 3 files changed, 25 insertions(+), 38 deletions(-) diff --git a/src/modules/processing/matchActionDecider.js b/src/modules/processing/matchActionDecider.js index 422d9a62..4efd0f12 100644 --- a/src/modules/processing/matchActionDecider.js +++ b/src/modules/processing/matchActionDecider.js @@ -145,10 +145,6 @@ export default function(r, host, audioFormat, isAudioOnly, lang, isAudioMuted, d } else if (audioFormat === "best") { audioFormat = "m4a"; copy = true; - if (!r.filenameAttributes && r.audioFilename.includes("twitterspaces")) { - audioFormat = "mp3" - copy = false - } } if (r.isM3U8 || host === "vimeo") { copy = false; diff --git a/src/modules/processing/services/vimeo.js b/src/modules/processing/services/vimeo.js index b60a1c39..90dc9b3d 100644 --- a/src/modules/processing/services/vimeo.js +++ b/src/modules/processing/services/vimeo.js @@ -63,40 +63,26 @@ export default async function(obj) { if (!masterJSON) return { error: 'ErrorCouldntFetch' }; if (!masterJSON.video) return { error: 'ErrorEmptyDownload' }; - let type = "parcel"; - if (masterJSON.base_url === "../") type = "chop"; - - let masterJSON_Video = masterJSON.video.sort((a, b) => Number(b.width) - Number(a.width)), + let masterJSON_Video = masterJSON.video.sort((a, b) => Number(b.width) - Number(a.width)).filter(a => a['format'] === "mp42"), bestVideo = masterJSON_Video[0]; - if (Number(quality) < Number(resolutionMatch[bestVideo["width"]])) bestVideo = masterJSON_Video.find(i => resolutionMatch[i["width"]] === quality); - - let videoUrl, audioUrl, baseUrl = masterJSONURL.split("/sep/")[0]; - switch (type) { - case "parcel": - let masterJSON_Audio = masterJSON.audio.sort((a, b) => Number(b.bitrate) - Number(a.bitrate)).filter(a => a['mime_type'] === "audio/mp4"), - bestAudio = masterJSON_Audio[0]; - videoUrl = `${baseUrl}/parcel/video/${bestVideo.index_segment.split('?')[0]}`, - audioUrl = `${baseUrl}/parcel/audio/${bestAudio.index_segment.split('?')[0]}`; - break; - case "chop": - videoUrl = `${baseUrl}/sep/video/${bestVideo.id}/master.m3u8`; - break; + if (Number(quality) < Number(resolutionMatch[bestVideo["width"]])) { + bestVideo = masterJSON_Video.find(i => resolutionMatch[i["width"]] === quality) } - if (videoUrl) { - return { - urls: audioUrl ? [videoUrl, audioUrl] : videoUrl, - isM3U8: audioUrl ? false : true, - fileMetadata: fileMetadata, - filenameAttributes: { - service: "vimeo", - id: obj.id, - title: fileMetadata.title, - author: fileMetadata.artist, - resolution: `${bestVideo["width"]}x${bestVideo["height"]}`, - qualityLabel: `${bestVideo["height"]}p`, - extension: "mp4" - } + + let masterM3U8 = `${masterJSONURL.split("/sep/")[0]}/sep/video/${bestVideo.id}/master.m3u8`; + + return { + urls: masterM3U8, + isM3U8: true, + fileMetadata: fileMetadata, + filenameAttributes: { + service: "vimeo", + id: obj.id, + title: fileMetadata.title, + author: fileMetadata.artist, + resolution: `${bestVideo["width"]}x${bestVideo["height"]}`, + qualityLabel: `${resolutionMatch[bestVideo["width"]]}p`, + extension: "mp4" } } - return { error: 'ErrorEmptyDownload' } } diff --git a/src/modules/stream/types.js b/src/modules/stream/types.js index 03a78205..c2bd2910 100644 --- a/src/modules/stream/types.js +++ b/src/modules/stream/types.js @@ -122,10 +122,15 @@ export function streamAudioOnly(streamInfo, res) { try { let args = [ - '-loglevel', '-8', + '-loglevel', '-8' + ] + if (streamInfo.service === "twitter") { + args.push('-seekable', '0') + } + args.push( '-i', streamInfo.urls, '-vn' - ] + ) if (streamInfo.metadata) { args = args.concat(metadataManager(streamInfo.metadata))