vxtwitter support

- moved out host overrides to its own file
- added mastodon verification
This commit is contained in:
wukko 2023-08-20 16:11:16 +06:00
parent 8304499ce7
commit a8cbebd240
6 changed files with 67 additions and 28 deletions

View file

@ -21,9 +21,10 @@ Paste the link, get the video, move on. It's that simple. Just how it should be.
| Pinterest | ✅ | ✅ | ✅ | Support for videos and stories. | | Pinterest | ✅ | ✅ | ✅ | Support for videos and stories. |
| Reddit | ✅ | ✅ | ✅ | Support for GIFs and videos. | | Reddit | ✅ | ✅ | ✅ | Support for GIFs and videos. |
| SoundCloud | | ✅ | | Audio metadata, downloads from private links. | | SoundCloud | | ✅ | | Audio metadata, downloads from private links. |
| Streamable | ✅ | ✅ | ✅ | |
| TikTok | ✅ | ✅ | ✅ | Supports downloads of: videos with or without watermark, images from slideshow without watermark, full (original) audios. | | TikTok | ✅ | ✅ | ✅ | Supports downloads of: videos with or without watermark, images from slideshow without watermark, full (original) audios. |
| Tumblr | ✅ | ✅ | ✅ | Support for audio file downloads. | | Tumblr | ✅ | ✅ | ✅ | Support for audio file downloads. |
| Twitter* | ✅ | ✅ | ✅ | Ability to pick what to save from multi-media tweets. | | Twitter/X * | ✅ | ✅ | ✅ | Ability to pick what to save from multi-media tweets. |
| Vimeo | ✅ | ✅ | ✅ | Audio downloads are only available for dash files. | | Vimeo | ✅ | ✅ | ✅ | Audio downloads are only available for dash files. |
| Vine Archive | ✅ | ✅ | ✅ | | | Vine Archive | ✅ | ✅ | ✅ | |
| VK Videos | ✅ | ❌ | ❌ | | | VK Videos | ✅ | ❌ | ❌ | |

View file

@ -6,6 +6,7 @@ import { cleanURL, apiJSON } from "./sub/utils.js";
import { errorUnsupported } from "./sub/errors.js"; import { errorUnsupported } from "./sub/errors.js";
import loc from "../localization/manager.js"; import loc from "../localization/manager.js";
import match from "./processing/match.js"; import match from "./processing/match.js";
import hostOverrides from "./processing/hostOverrides.js";
export async function getJSON(originalURL, lang, obj) { export async function getJSON(originalURL, lang, obj) {
try { try {
@ -15,32 +16,10 @@ export async function getJSON(originalURL, lang, obj) {
if (!url.startsWith('https://')) return apiJSON(0, { t: errorUnsupported(lang) }); if (!url.startsWith('https://')) return apiJSON(0, { t: errorUnsupported(lang) });
switch(host) { let overrides = hostOverrides(host, url);
case "youtu": host = overrides.host;
if (url.startsWith("https://youtu.be/")) { url = overrides.url;
host = "youtube";
url = `https://youtube.com/watch?v=${url.replace("https://youtu.be/", "")}`;
}
break;
case "goo":
if (url.substring(0, 30) === "https://soundcloud.app.goo.gl/") {
host = "soundcloud";
url = `https://soundcloud.com/${url.replace("https://soundcloud.app.goo.gl/", "").split('/')[0]}`
}
break;
case "x":
if (url.startsWith("https://x.com/")) {
host = "twitter";
url = url.replace("https://x.com/", "https://twitter.com/")
}
break;
case "tumblr":
if (!url.includes("blog/view")) {
if (url.slice(-1) === '/') url = url.slice(0, -1);
url = url.replace(url.split('/')[5], '')
}
break;
}
if (!(host && host.length < 20 && host in patterns && patterns[host]["enabled"])) return apiJSON(0, { t: errorUnsupported(lang) }); if (!(host && host.length < 20 && host in patterns && patterns[host]["enabled"])) return apiJSON(0, { t: errorUnsupported(lang) });
let pathToMatch = cleanURL(url, host).split(`.${patterns[host]['tld'] ? patterns[host]['tld'] : "com"}/`)[1].replace('.', ''); let pathToMatch = cleanURL(url, host).split(`.${patterns[host]['tld'] ? patterns[host]['tld'] : "com"}/`)[1].replace('.', '');

View file

@ -73,6 +73,8 @@ export default function(obj) {
<link rel="stylesheet" href="fonts/notosansmono.css" rel="preload" /> <link rel="stylesheet" href="fonts/notosansmono.css" rel="preload" />
<link rel="stylesheet" href="cobalt.css" /> <link rel="stylesheet" href="cobalt.css" />
<link rel="me" href="${authorInfo.support.mastodon.url}">
<noscript><div style="margin: 2rem;">${t('NoScriptMessage')}</div></noscript> <noscript><div style="margin: 2rem;">${t('NoScriptMessage')}</div></noscript>
</head> </head>
<body id="cobalt-body" ${platform === "p" ? 'class="desktop"' : ''} data-nosnippet ontouchstart> <body id="cobalt-body" ${platform === "p" ? 'class="desktop"' : ''} data-nosnippet ontouchstart>

View file

@ -0,0 +1,41 @@
export default function (inHost, inURL) {
let host = String(inHost);
let url = String(inURL);
switch(host) {
case "youtu":
if (url.startsWith("https://youtu.be/")) {
host = "youtube";
url = `https://youtube.com/watch?v=${url.replace("https://youtu.be/", "")}`;
}
break;
case "goo":
if (url.startsWith("https://soundcloud.app.goo.gl/")) {
host = "soundcloud";
url = `https://soundcloud.com/${url.replace("https://soundcloud.app.goo.gl/", "").split('/')[0]}`
}
break;
case "vxtwitter":
case "x":
if (url.startsWith("https://x.com/")) {
host = "twitter";
url = url.replace("https://x.com/", "https://twitter.com/")
}
if (url.startsWith("https://vxtwitter.com/")) {
host = "twitter";
url = url.replace("https://vxtwitter.com/", "https://twitter.com/")
}
break;
case "tumblr":
if (!url.includes("blog/view")) {
if (url.slice(-1) === '/') url = url.slice(0, -1);
url = url.replace(url.split('/')[5], '')
}
break;
}
return {
host: host,
url: url
}
}

View file

@ -1,5 +1,6 @@
import { maxVideoDuration } from "../../config.js"; import { maxVideoDuration } from "../../config.js";
// vimeo you're fucked in the head for this
const resolutionMatch = { const resolutionMatch = {
"3840": "2160", "3840": "2160",
"2732": "1440", "2732": "1440",
@ -11,7 +12,6 @@ const resolutionMatch = {
"640": "360", "640": "360",
"426": "240" "426": "240"
} }
// ^ vimeo you're fucked in the head for this ^
const qualityMatch = { const qualityMatch = {
"2160": "4K", "2160": "4K",

View file

@ -111,6 +111,22 @@
"code": 200, "code": 200,
"status": "redirect" "status": "redirect"
} }
}, {
"name": "twitter voice + x.com link",
"url": "https://x.com/eggsaladscreams/status/1693089534886506756?s=46",
"params": {},
"expected": {
"code": 200,
"status": "redirect"
}
}, {
"name": "vxtwitter link",
"url": "https://vxtwitter.com/dustbin_nie/status/1624596567188717568?s=20",
"params": {},
"expected": {
"code": 200,
"status": "redirect"
}
}, { }, {
"name": "retweeted video, isAudioOnly", "name": "retweeted video, isAudioOnly",
"url": "https://twitter.com/hugekiwinuts/status/1618671150829309953?s=46&t=gItGzgwGQQJJaJrO6qc1Pg", "url": "https://twitter.com/hugekiwinuts/status/1618671150829309953?s=46&t=gItGzgwGQQJJaJrO6qc1Pg",