Skip to content

Commit b04e2bb

Browse files
committed
api/twitter: strip "tag" param from video urls
1 parent 1ad54bc commit b04e2bb

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

api/src/processing/services/twitter.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,19 @@ function needsFixing(media) {
3737
}
3838

3939
function bestQuality(arr) {
40-
return arr.filter(v => v.content_type === "video/mp4")
40+
return stripVideoURL(
41+
arr.filter(v => v.content_type === "video/mp4")
4142
.reduce((a, b) => Number(a?.bitrate) > Number(b?.bitrate) ? a : b)
4243
.url
44+
);
45+
}
46+
47+
function stripVideoURL(maybeUrl) {
48+
if (maybeUrl) {
49+
const url = new URL(maybeUrl);
50+
url.searchParams.delete('tag');
51+
return url.toString();
52+
}
4353
}
4454

4555
let _cachedToken;

0 commit comments

Comments
 (0)