From 604a56c5142fa433903500153940837fc77b6429 Mon Sep 17 00:00:00 2001 From: ManeraKai Date: Tue, 14 Feb 2023 18:24:10 +0300 Subject: [PATCH] Added Tent https://codeberg.org/LibRedirect/libredirect/issues/76 --- src/assets/images/bandcamp-icon.svg | 175 ++++++++++++++++++++++++++++ src/assets/javascripts/services.js | 36 ++++++ src/config.json | 25 +++- 3 files changed, 234 insertions(+), 2 deletions(-) create mode 100644 src/assets/images/bandcamp-icon.svg diff --git a/src/assets/images/bandcamp-icon.svg b/src/assets/images/bandcamp-icon.svg new file mode 100644 index 00000000..8b1e7f52 --- /dev/null +++ b/src/assets/images/bandcamp-icon.svg @@ -0,0 +1,175 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/assets/javascripts/services.js b/src/assets/javascripts/services.js index e8315ff5..7e0b5937 100644 --- a/src/assets/javascripts/services.js +++ b/src/assets/javascripts/services.js @@ -508,6 +508,41 @@ function redirect(url, type, initiator, forceRedirection) { return `${randomInstance}/space${url.pathname}${url.search}` } } + case "tent": { + if (url.hostname == 'bandcamp.com' && url.pathname == '/search') { + const query = url.searchParams.get('q') + return `${randomInstance}/search.php?query=${encodeURIComponent(query)}` + } + if (url.hostname.endsWith('bandcamp.com')) { + const regex = /^(.*)\.bandcamp\.com/.exec(url.hostname) + const artist = regex[1] + if (url.pathname == '/') { + return `${randomInstance}/artist.php?name=${artist}` + } else { + const regex = /^\/(.*)\/(.*)/.exec(url.pathname) + if (regex) { + const type = regex[1] + const name = regex[2] + return `${randomInstance}/release.php?artist=${artist}&type=${type}&name=${name}` + } + } + } + if (url.hostname == 'f4.bcbits.com') { + const regex = /\/img\/(.*)/.exec(url.pathname) + const image = regex[1] + return `${randomInstance}/image.php?file=${image}` + } + if (url.hostname == 't4.bcbits.com') { + const regex = /\/stream\/(.*)\/(.*)\/(.*)/.exec(url.pathname) + if (regex) { + const directory = regex[1] + const format = regex[2] + const file = regex[3] + const token = url.searchParams.get('token') + return `${randomInstance}/audio.php/?directory=${directory}&format=${format}&file=${file}&token=${encodeURIComponent(token)}` + } + } + } default: { return `${randomInstance}${url.pathname}${url.search}` } @@ -639,6 +674,7 @@ const defaultInstances = { 'waybackClassic': ['https://wayback-classic.net'], 'gothub': ['https://gh.odyssey346.dev'], 'mikuIndividious': ['https://mikuinv.resrv.org'], + "tent": ['https://tent.sny.sh'] } function initDefaults() { diff --git a/src/config.json b/src/config.json index 57e190ad..44d075ac 100644 --- a/src/config.json +++ b/src/config.json @@ -675,8 +675,8 @@ }, "bilibili": { "frontends": { - "mikuIndividious": { - "name": "MikuIndividious", + "mikuInvidious": { + "name": "MikuInvidious", "instanceList": true, "url": "https://0xacab.org/johnxina/mikuinvidious" } @@ -693,6 +693,27 @@ "imageType": "svgMono", "embeddable": false, "url": "https://bilibili.com/" + }, + "bandcamp": { + "frontends": { + "tent": { + "name": "Tent", + "instanceList": true, + "url": "https://codeberg.org/sun/Tent" + } + }, + "targets": [ + "^https?:\\/{2}(.*\\.)?bandcamp\\.com\\/", + "^https?:\\/{2}(f4|t4)\\.bcbits\\.com\\/" + ], + "name": "Bandcamp", + "options": { + "enabled": false, + "unsupportedUrls": "bypass" + }, + "imageType": "svg", + "embeddable": false, + "url": "https://bandcamp.com/" } } } \ No newline at end of file