Skip to content

best way to save what you love

api/twitter: strip "tag" param from video urls

jje6bbd9477ccb
diff --git a/api/src/processing/services/twitter.js b/api/src/processing/services/twitter.js
index 572bc2f0..463b0589 100644
--- a/api/src/processing/services/twitter.js
+++ b/api/src/processing/services/twitter.js
@@ -37,9 +37,19 @@ function needsFixing(media) {
}
function bestQuality(arr) {
- return arr.filter(v => v.content_type === "video/mp4")
+ return stripVideoURL(
+ arr.filter(v => v.content_type === "video/mp4")
.reduce((a, b) => Number(a?.bitrate) > Number(b?.bitrate) ? a : b)
.url
+ );
+}
+
+function stripVideoURL(maybeUrl) {
+ if (maybeUrl) {
+ const url = new URL(maybeUrl);
+ url.searchParams.delete('tag');
+ return url.toString();
+ }
}
let _cachedToken;