remade localization system once again
- new localization system: fast, dynamic, way more organized - localization strings are WAY more descriptive - it's now easier to add support for other languages (just one loc file instead of five) - localization now falls back to english if localized string isnt available - got rid of all static language selectors (probably) - slightly updated english and russian strings - miscellaneous settings items have been bundled together and moved to the bottom, cause they're used the least - bottom links should no longer touch the popup border on overflow - rearranged popup order in the rendered page - bumped version up to 2.2.5 if you see strings that are like this: !!EXAMPLE!! or withoutspace please file an issue on github
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import got from "got";
|
||||
import loc from "../sub/i18n.js";
|
||||
import loc from "../../localization/manager.js";
|
||||
import { genericUserAgent, maxVideoDuration } from "../config.js";
|
||||
|
||||
export default async function(obj) {
|
||||
@@ -8,7 +8,7 @@ export default async function(obj) {
|
||||
headers: { "user-agent": genericUserAgent }
|
||||
});
|
||||
html.on('error', (err) => {
|
||||
return { error: loc(obj.lang, 'apiError', 'cantConnectToAPI', 'bilibili') };
|
||||
return { error: loc(obj.lang, 'ErrorCantConnectToServiceAPI', 'bilibili') };
|
||||
});
|
||||
html = html.body;
|
||||
if (html.includes('<script>window.__playinfo__=') && html.includes('"video_codecid"')) {
|
||||
@@ -22,13 +22,13 @@ export default async function(obj) {
|
||||
}).sort((a, b) => Number(b.bandwidth) - Number(a.bandwidth));
|
||||
return { urls: [video[0]["baseUrl"], audio[0]["baseUrl"]], time: streamData.data.timelength, filename: `bilibili_${obj.id}_${video[0]["width"]}x${video[0]["height"]}.mp4` };
|
||||
} else {
|
||||
return { error: loc(obj.lang, 'apiError', 'lengthLimit', maxVideoDuration / 60000) };
|
||||
return { error: loc(obj.lang, 'ErrorLengthLimit', maxVideoDuration / 60000) };
|
||||
}
|
||||
} else {
|
||||
return { error: loc(obj.lang, 'apiError', 'nothingToDownload') };
|
||||
return { error: loc(obj.lang, 'ErrorEmptyDownload') };
|
||||
}
|
||||
} catch (e) {
|
||||
return { error: loc(obj.lang, 'apiError', 'noFetch') };
|
||||
return { error: loc(obj.lang, 'ErrorBadFetch') };
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import got from "got";
|
||||
import loc from "../sub/i18n.js";
|
||||
import loc from "../../localization/manager.js";
|
||||
import { genericUserAgent, maxVideoDuration } from "../config.js";
|
||||
|
||||
export default async function(obj) {
|
||||
@@ -20,9 +20,9 @@ export default async function(obj) {
|
||||
return { typeId: 1, urls: video};
|
||||
}
|
||||
} else {
|
||||
return { error: loc(obj.lang, 'apiError', 'nothingToDownload') };
|
||||
return { error: loc(obj.lang, 'ErrorEmptyDownload') };
|
||||
}
|
||||
} catch (err) {
|
||||
return { error: loc(obj.lang, 'apiError', 'noFetch') };
|
||||
return { error: loc(obj.lang, 'ErrorBadFetch') };
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,11 @@
|
||||
import got from "got";
|
||||
import loc from "../sub/i18n.js";
|
||||
import loc from "../../localization/manager.js";
|
||||
import { services } from "../config.js";
|
||||
|
||||
const configSt = services.twitter;
|
||||
|
||||
async function fetchTweetInfo(obj) {
|
||||
let cantConnect = { error: loc('en', 'apiError', 'cantConnectToAPI', 'twitter') }
|
||||
let cantConnect = { error: loc(obj.lang, 'ErrorCantConnectToServiceAPI', 'twitter') }
|
||||
try {
|
||||
let _headers = {
|
||||
"Authorization": `Bearer ${configSt.token}`,
|
||||
@@ -28,11 +28,11 @@ async function fetchTweetInfo(obj) {
|
||||
})
|
||||
return JSON.parse(req_status.body);
|
||||
} catch (err) {
|
||||
return { error: cantConnect };
|
||||
return cantConnect;
|
||||
}
|
||||
}
|
||||
export default async function (obj) {
|
||||
let nothing = { error: loc('en', 'apiError', 'nothingToDownload') }
|
||||
let nothing = { error: loc(obj.lang, 'ErrorEmptyDownload') }
|
||||
try {
|
||||
let parsbod = await fetchTweetInfo(obj);
|
||||
if (!parsbod.error) {
|
||||
@@ -52,6 +52,6 @@ export default async function (obj) {
|
||||
}
|
||||
} else return parsbod;
|
||||
} catch (err) {
|
||||
return { error: loc("en", "apiError", "errorFetch") };
|
||||
return { error: loc(obj.lang, 'ErrorBadFetch') };
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
import got from "got";
|
||||
import { xml2json } from "xml-js";
|
||||
import loc from "../sub/i18n.js";
|
||||
import loc from "../../localization/manager.js";
|
||||
import { genericUserAgent, maxVideoDuration, services } from "../config.js";
|
||||
import selectQuality from "../stream/selectQuality.js";
|
||||
|
||||
@@ -30,18 +30,18 @@ export default async function(obj) {
|
||||
if (selectedQuality in js["player"]["params"][0]) {
|
||||
return { url: js["player"]["params"][0][selectedQuality].replace(`type=${maxQuality}`, `type=${services.vk.quality_match[userQuality]}`), filename: `vk_${js["player"]["params"][0][selectedQuality].split("id=")[1]}_${attr['width']}x${attr['height']}.mp4` };
|
||||
} else {
|
||||
return { error: loc(obj.lang, 'apiError', 'nothingToDownload') };
|
||||
return { error: loc(obj.lang, 'ErrorEmptyDownload') };
|
||||
}
|
||||
} else {
|
||||
return { error: loc(obj.lang, 'apiError', 'lengthLimit', maxVideoDuration / 60000) };
|
||||
return { error: loc(obj.lang, 'ErrorLengthLimit', maxVideoDuration / 60000) };
|
||||
}
|
||||
} else {
|
||||
return { error: loc(obj.lang, 'apiError', 'liveVideo') };
|
||||
return { error: loc(obj.lang, 'ErrorLiveVideo') };
|
||||
}
|
||||
} else {
|
||||
return { error: loc(obj.lang, 'apiError', 'nothingToDownload') };
|
||||
return { error: loc(obj.lang, 'ErrorEmptyDownload') };
|
||||
}
|
||||
} catch (err) {
|
||||
return { error: loc(obj.lang, 'apiError', 'errorFetch') };
|
||||
return { error: loc(obj.lang, 'ErrorBadFetch') };
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
import ytdl from "ytdl-core";
|
||||
import loc from "../sub/i18n.js";
|
||||
import loc from "../../localization/manager.js";
|
||||
import { maxVideoDuration, quality as mq } from "../config.js";
|
||||
import selectQuality from "../stream/selectQuality.js";
|
||||
|
||||
@@ -48,7 +48,7 @@ export default async function (obj) {
|
||||
filename: `youtube_${obj.id}_${videoMatch[0]["width"]}x${videoMatch[0]["height"]}.${obj.format}` };
|
||||
}
|
||||
} else {
|
||||
return { error: loc('en', 'apiError', 'errorFetch') };
|
||||
return { error: loc(obj.lang, 'ErrorBadFetch') };
|
||||
}
|
||||
} else if (!obj.isAudioOnly) {
|
||||
return { type: "render", urls: [video[0]["url"], audio[0]["url"]], time: video[0]["approxDurationMs"],
|
||||
@@ -56,19 +56,19 @@ export default async function (obj) {
|
||||
} else if (audio.length > 0) {
|
||||
return { type: "render", isAudioOnly: true, urls: [audio[0]["url"]], filename: `youtube_${obj.id}_${audio[0]["audioBitrate"]}kbps.opus` };
|
||||
} else {
|
||||
return { error: loc('en', 'apiError', 'errorFetch') };
|
||||
return { error: loc(obj.lang, 'ErrorBadFetch') };
|
||||
}
|
||||
} else {
|
||||
return { error: loc('en', 'apiError', 'lengthLimit', maxVideoDuration / 60000) };
|
||||
return { error: loc(obj.lang, 'ErrorLengthLimit', maxVideoDuration / 60000) };
|
||||
}
|
||||
} else {
|
||||
return { error: loc('en', 'apiError', 'liveVideo') };
|
||||
return { error: loc(obj.lang, 'ErrorLiveVideo') };
|
||||
}
|
||||
} else {
|
||||
return { error: loc('en', 'apiError', 'youtubeFetch') };
|
||||
return { error: loc(obj.lang, 'ErrorCantConnectToServiceAPI') };
|
||||
}
|
||||
} catch (e) {
|
||||
return { error: loc('en', 'apiError', 'youtubeFetch') };
|
||||
return { error: loc(obj.lang, 'ErrorBadFetch') };
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user