Skip to content

Commit

Permalink
fix: subtitles
Browse files Browse the repository at this point in the history
  • Loading branch information
tymmesyde committed Feb 3, 2024
1 parent 814a19b commit e029e80
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 25 deletions.
2 changes: 1 addition & 1 deletion src/common/config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const CINEMETA_URL = "https://v3-cinemeta.strem.io";
const OPENSUBTITLES_URL = "https://opensubtitles.strem.io";
const OPENSUBTITLES_URL = "https://opensubtitles-v3.strem.io";
const STREMIO_API_URL = "https://api.strem.io";
const STREMIO_STREAMING_SERVER = "http://localhost:11470";
const ADDON_COMMUNITY_LIST = 'https://stremio-addons.netlify.app/';
Expand Down
11 changes: 9 additions & 2 deletions src/components/player/controls/Subtitles.vue
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,15 @@ export default {
this.list = urls.map(url => this.list.find(sub => sub.url === url));
};
StremioService.getSubtitles(this.videoUrl).then(stremioSubtitles => addToList(stremioSubtitles));
this.installedSubtitles.map(addon => AddonService.getSubtitles([addon], this.meta.type, this.meta.id).then(addonsSubtitles => addToList(addonsSubtitles)));
StremioService.getSubtitles({
type: this.meta.type,
id: this.meta.id,
url: this.videoUrl,
}).then(stremioSubtitles => addToList(stremioSubtitles));
this.installedSubtitles
.map(addon => AddonService.getSubtitles([addon], this.meta.type, this.meta.id)
.then(addonsSubtitles => addToList(addonsSubtitles)));
},
filterSubs() {
return this.panelLang ? this.list.filter(s => s.lang === this.panelLang.iso) : [];
Expand Down
32 changes: 10 additions & 22 deletions src/services/stremio.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,26 +52,14 @@ const StremioService = {
return data;
},

async getSubtitles(streamUrl) {
async getSubtitles({ type, id, url }) {
try {
const { hash, size } = await getOpenSubInfo(streamUrl);

const jsonrpc = JSON.stringify({
jsonrpc: '2.0',
id: 1,
method: 'subtitles.find',
params: [
null,
{
query: {
videoHash: hash,
videoSize: size
}
}
]
const { hash } = await getOpenSubInfo(url);
return queryOpenSubtitles({
type,
id,
videoHash: hash,
});

return queryOpenSubtitles(jsonrpc);
} catch(_) {
return [];
}
Expand All @@ -85,10 +73,10 @@ async function getOpenSubInfo(streamUrl) {
return result;
}

async function queryOpenSubtitles(jsonrpc) {
const { data } = await axios.get(`${OPENSUBTITLES_URL}/q.json?b=${btoa(jsonrpc)}`);
const { result } = data;
return result.all;
async function queryOpenSubtitles({ type, id, videoHash }) {
const { data } = await axios.get(`${OPENSUBTITLES_URL}/subtitles/${type}/${id}/videoHash=${videoHash}.json`);
const { subtitles } = data;
return subtitles;
}

export default StremioService;

0 comments on commit e029e80

Please sign in to comment.