api: convert service config to JS and remove it from main config
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
import { audioIgnore, services, supportedAudio } from "../config.js";
|
||||
import { supportedAudio } from "../config.js";
|
||||
import { audioIgnore, services } from "./service-config.js";
|
||||
|
||||
import { createResponse } from "./request.js";
|
||||
import createFilename from "./create-filename.js";
|
||||
import { createStream } from "../stream/manage.js";
|
||||
|
||||
197
api/src/processing/service-config.js
Normal file
197
api/src/processing/service-config.js
Normal file
@@ -0,0 +1,197 @@
|
||||
import UrlPattern from "url-pattern";
|
||||
|
||||
export const audioIgnore = ["vk", "ok", "loom"];
|
||||
export const hlsExceptions = ["dailymotion", "vimeo", "rutube"];
|
||||
|
||||
export const services = {
|
||||
bilibili: {
|
||||
enabled: true,
|
||||
patterns: [
|
||||
"video/:comId",
|
||||
"_shortLink/:comShortLink",
|
||||
"_tv/:lang/video/:tvId",
|
||||
"_tv/video/:tvId"
|
||||
],
|
||||
subdomains: ["m"],
|
||||
},
|
||||
dailymotion: {
|
||||
enabled: true,
|
||||
patterns: ["video/:id"],
|
||||
},
|
||||
facebook: {
|
||||
enabled: true,
|
||||
patterns: [
|
||||
"_shortLink/:shortLink",
|
||||
":username/videos/:caption/:id",
|
||||
":username/videos/:id",
|
||||
"reel/:id",
|
||||
"share/:shareType/:id"
|
||||
],
|
||||
subdomains: ["web"],
|
||||
altDomains: ["fb.watch"],
|
||||
},
|
||||
instagram: {
|
||||
enabled: true,
|
||||
patterns: [
|
||||
"reels/:postId",
|
||||
":username/reel/:postId",
|
||||
"reel/:postId",
|
||||
"p/:postId",
|
||||
":username/p/:postId",
|
||||
"tv/:postId",
|
||||
"stories/:username/:storyId"
|
||||
],
|
||||
altDomains: ["ddinstagram.com"],
|
||||
},
|
||||
loom: {
|
||||
enabled: true,
|
||||
patterns: ["share/:id"],
|
||||
},
|
||||
ok: {
|
||||
enabled: true,
|
||||
patterns: [
|
||||
"video/:id",
|
||||
"videoembed/:id"
|
||||
],
|
||||
tld: "ru",
|
||||
},
|
||||
pinterest: {
|
||||
enabled: true,
|
||||
patterns: [
|
||||
"pin/:id",
|
||||
"pin/:id/:garbage",
|
||||
"url_shortener/:shortLink"
|
||||
],
|
||||
},
|
||||
reddit: {
|
||||
enabled: true,
|
||||
patterns: [
|
||||
"r/:sub/comments/:id/:title",
|
||||
"user/:user/comments/:id/:title"
|
||||
],
|
||||
subdomains: "*",
|
||||
},
|
||||
rutube: {
|
||||
enabled: true,
|
||||
patterns: [
|
||||
"video/:id",
|
||||
"play/embed/:id",
|
||||
"shorts/:id",
|
||||
"yappy/:yappyId",
|
||||
"video/private/:id?p=:key",
|
||||
"video/private/:id"
|
||||
],
|
||||
tld: "ru",
|
||||
},
|
||||
snapchat: {
|
||||
enabled: true,
|
||||
patterns: [
|
||||
":shortLink",
|
||||
"spotlight/:spotlightId",
|
||||
"add/:username/:storyId",
|
||||
"u/:username/:storyId",
|
||||
"add/:username",
|
||||
"u/:username"
|
||||
],
|
||||
subdomains: ["t", "story"],
|
||||
},
|
||||
soundcloud: {
|
||||
enabled: true,
|
||||
patterns: [
|
||||
":author/:song/s-:accessKey",
|
||||
":author/:song",
|
||||
":shortLink"
|
||||
],
|
||||
subdomains: ["on", "m"],
|
||||
},
|
||||
streamable: {
|
||||
enabled: true,
|
||||
patterns: [
|
||||
":id",
|
||||
"o/:id",
|
||||
"e/:id",
|
||||
"s/:id"
|
||||
],
|
||||
},
|
||||
tiktok: {
|
||||
enabled: true,
|
||||
patterns: [
|
||||
":user/video/:postId",
|
||||
":id",
|
||||
"t/:id",
|
||||
":user/photo/:postId",
|
||||
"v/:id.html"
|
||||
],
|
||||
subdomains: ["vt", "vm", "m"],
|
||||
},
|
||||
tumblr: {
|
||||
enabled: true,
|
||||
patterns: [
|
||||
"post/:id",
|
||||
"blog/view/:user/:id",
|
||||
":user/:id",
|
||||
":user/:id/:trackingId"
|
||||
],
|
||||
subdomains: "*",
|
||||
},
|
||||
twitch: {
|
||||
enabled: true,
|
||||
patterns: [":channel/clip/:clip"],
|
||||
tld: "tv",
|
||||
},
|
||||
twitter: {
|
||||
enabled: true,
|
||||
patterns: [
|
||||
":user/status/:id",
|
||||
":user/status/:id/video/:index",
|
||||
":user/status/:id/photo/:index",
|
||||
":user/status/:id/mediaviewer",
|
||||
":user/status/:id/mediaViewer"
|
||||
],
|
||||
subdomains: ["mobile"],
|
||||
altDomains: ["x.com", "vxtwitter.com", "fixvx.com"],
|
||||
},
|
||||
vine: {
|
||||
enabled: true,
|
||||
patterns: ["v/:id"],
|
||||
tld: "co",
|
||||
},
|
||||
vimeo: {
|
||||
enabled: true,
|
||||
patterns: [
|
||||
":id",
|
||||
"video/:id",
|
||||
":id/:password",
|
||||
"/channels/:user/:id"
|
||||
],
|
||||
subdomains: ["player"],
|
||||
bestAudio: "mp3",
|
||||
},
|
||||
vk: {
|
||||
enabled: true,
|
||||
patterns: [
|
||||
"video:userId_:videoId",
|
||||
"clip:userId_:videoId",
|
||||
"clips:duplicate?z=clip:userId_:videoId"
|
||||
],
|
||||
subdomains: ["m"],
|
||||
},
|
||||
youtube: {
|
||||
enabled: true,
|
||||
patterns: [
|
||||
"watch?v=:id",
|
||||
"embed/:id",
|
||||
"watch/:id"
|
||||
],
|
||||
subdomains: ["music", "m"],
|
||||
bestAudio: "opus",
|
||||
}
|
||||
}
|
||||
|
||||
Object.values(services).forEach(service => {
|
||||
service.patterns = service.patterns.map(
|
||||
pattern => new UrlPattern(pattern, {
|
||||
segmentValueCharset: UrlPattern.defaultOptions.segmentValueCharset + '@\\.'
|
||||
})
|
||||
)
|
||||
})
|
||||
@@ -1,142 +0,0 @@
|
||||
{
|
||||
"audioIgnore": ["vk", "ok", "loom"],
|
||||
"hlsExceptions": ["dailymotion", "vimeo", "rutube"],
|
||||
"config": {
|
||||
"bilibili": {
|
||||
"alias": "bilibili.com & bilibili.tv",
|
||||
"patterns": [
|
||||
"video/:comId", "_shortLink/:comShortLink",
|
||||
"_tv/:lang/video/:tvId", "_tv/video/:tvId"
|
||||
],
|
||||
"subdomains": ["m"],
|
||||
"enabled": true
|
||||
},
|
||||
"reddit": {
|
||||
"alias": "reddit videos & gifs",
|
||||
"patterns": ["r/:sub/comments/:id/:title", "user/:user/comments/:id/:title"],
|
||||
"subdomains": "*",
|
||||
"enabled": true
|
||||
},
|
||||
"twitter": {
|
||||
"alias": "twitter videos & voice",
|
||||
"altDomains": ["x.com", "vxtwitter.com", "fixvx.com"],
|
||||
"subdomains": ["mobile"],
|
||||
"patterns": [
|
||||
":user/status/:id",
|
||||
":user/status/:id/video/:index",
|
||||
":user/status/:id/photo/:index",
|
||||
":user/status/:id/mediaviewer",
|
||||
":user/status/:id/mediaViewer"
|
||||
],
|
||||
"enabled": true
|
||||
},
|
||||
"vk": {
|
||||
"alias": "vk video & clips",
|
||||
"patterns": ["video:userId_:videoId", "clip:userId_:videoId", "clips:duplicate?z=clip:userId_:videoId"],
|
||||
"subdomains": ["m"],
|
||||
"enabled": true
|
||||
},
|
||||
"ok": {
|
||||
"alias": "ok video",
|
||||
"tld": "ru",
|
||||
"patterns": ["video/:id", "videoembed/:id"],
|
||||
"enabled": true
|
||||
},
|
||||
"youtube": {
|
||||
"alias": "youtube videos, shorts & music",
|
||||
"patterns": ["watch?v=:id", "embed/:id", "watch/:id"],
|
||||
"subdomains": ["music", "m"],
|
||||
"bestAudio": "opus",
|
||||
"enabled": true
|
||||
},
|
||||
"tumblr": {
|
||||
"alias": "tumblr video & audio",
|
||||
"patterns": ["post/:id", "blog/view/:user/:id", ":user/:id", ":user/:id/:trackingId"],
|
||||
"subdomains": "*",
|
||||
"enabled": true
|
||||
},
|
||||
"tiktok": {
|
||||
"alias": "tiktok videos, photos & audio",
|
||||
"patterns": [":user/video/:postId", ":id", "t/:id", ":user/photo/:postId", "v/:id.html"],
|
||||
"subdomains": ["vt", "vm", "m"],
|
||||
"enabled": true
|
||||
},
|
||||
"vimeo": {
|
||||
"patterns": [":id", "video/:id", ":id/:password", "/channels/:user/:id"],
|
||||
"subdomains": ["player"],
|
||||
"bestAudio": "mp3",
|
||||
"enabled": true
|
||||
},
|
||||
"soundcloud": {
|
||||
"patterns": [":author/:song/s-:accessKey", ":author/:song", ":shortLink"],
|
||||
"subdomains": ["on", "m"],
|
||||
"enabled": true
|
||||
},
|
||||
"instagram": {
|
||||
"alias": "instagram posts & reels",
|
||||
"altDomains": ["ddinstagram.com"],
|
||||
"patterns": [
|
||||
"reels/:postId", ":username/reel/:postId", "reel/:postId", "p/:postId", ":username/p/:postId",
|
||||
"tv/:postId", "stories/:username/:storyId"
|
||||
],
|
||||
"enabled": true
|
||||
},
|
||||
"vine": {
|
||||
"alias": "vine archive",
|
||||
"tld": "co",
|
||||
"patterns": ["v/:id"],
|
||||
"enabled": true
|
||||
},
|
||||
"pinterest": {
|
||||
"alias": "pinterest (all media)",
|
||||
"patterns": ["pin/:id", "pin/:id/:garbage", "url_shortener/:shortLink"],
|
||||
"enabled": true
|
||||
},
|
||||
"streamable": {
|
||||
"alias": "streamable.com",
|
||||
"patterns": [":id", "o/:id", "e/:id", "s/:id"],
|
||||
"enabled": true
|
||||
},
|
||||
"twitch": {
|
||||
"alias": "twitch clips",
|
||||
"tld": "tv",
|
||||
"patterns": [":channel/clip/:clip"],
|
||||
"enabled": true
|
||||
},
|
||||
"rutube": {
|
||||
"alias": "rutube videos",
|
||||
"tld": "ru",
|
||||
"patterns": ["video/:id", "play/embed/:id", "shorts/:id", "yappy/:yappyId", "video/private/:id?p=:key", "video/private/:id"],
|
||||
"enabled": true
|
||||
},
|
||||
"dailymotion": {
|
||||
"alias": "dailymotion videos",
|
||||
"patterns": ["video/:id"],
|
||||
"enabled": true
|
||||
},
|
||||
"snapchat": {
|
||||
"alias": "snapchat stories & spotlights",
|
||||
"subdomains": ["t", "story"],
|
||||
"patterns": [":shortLink", "spotlight/:spotlightId", "add/:username/:storyId", "u/:username/:storyId", "add/:username", "u/:username"],
|
||||
"enabled": true
|
||||
},
|
||||
"loom": {
|
||||
"alias": "loom videos",
|
||||
"patterns": ["share/:id"],
|
||||
"enabled": true
|
||||
},
|
||||
"facebook": {
|
||||
"alias": "facebook videos",
|
||||
"altDomains": ["fb.watch"],
|
||||
"subdomains": ["web"],
|
||||
"patterns": [
|
||||
"_shortLink/:shortLink",
|
||||
":username/videos/:caption/:id",
|
||||
":username/videos/:id",
|
||||
"reel/:id",
|
||||
"share/:shareType/:id"
|
||||
],
|
||||
"enabled": true
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import { services } from "../config.js";
|
||||
import { services } from "./service-config.js";
|
||||
import { strict as assert } from "node:assert";
|
||||
import psl from "psl";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user