Skip to content

Commit

Permalink
Merge pull request #53 from AncientCatz/main
Browse files Browse the repository at this point in the history
Added "Preferred quality" option
  • Loading branch information
OshekharO authored Sep 30, 2023
2 parents df3d746 + 8b64bd3 commit 347dea4
Showing 1 changed file with 22 additions and 5 deletions.
27 changes: 22 additions & 5 deletions repo/gogo.anime.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,16 @@ export default class extends Extension {
title: "GoGo API",
key: "gogoApi",
type: "input",
description: "GoGo Api Url",
description: "API URL",
defaultValue: "https://api.consumet.org/anime/gogoanime",
});
this.registerSetting({
title: "Preferred quality",
key: "prefQuality",
type: "input",
description: "Choose between 360p/480p/720p/1080p",
defaultValue: "480p",
});
}

async latest(page) {
Expand Down Expand Up @@ -66,10 +73,20 @@ export default class extends Extension {
}

async watch(url) {
const quality = await this.getSetting("prefQuality");
const res = await this.req(`/watch/${url}?server=gogocdn`);
return {
type: "hls",
url: res.sources.pop().url,
};
const prefQuality = res.sources.find(source => source.quality === quality);

if (prefQuality) {
return {
type: "hls",
url: prefQuality.url,
};
} else {
return {
type: "hls",
url: res.sources.pop().url,
};
}
}
}

0 comments on commit 347dea4

Please sign in to comment.