diff options
| author | Bobby <[email protected]> | 2024-09-02 18:30:57 -0400 |
|---|---|---|
| committer | Bobby <[email protected]> | 2024-09-02 18:30:57 -0400 |
| commit | 773af5c376e2bef6fad28398b5add3c022c1dbf5 (patch) | |
| tree | 7f890355d08566cb242bdc55fa7c43b3ded76f6d | |
| parent | 74eeb6f0f5d20e22e7e32de381017dd1782e7657 (diff) | |
| download | yugen-773af5c376e2bef6fad28398b5add3c022c1dbf5.tar.xz yugen-773af5c376e2bef6fad28398b5add3c022c1dbf5.zip | |
quality persisitance
| -rw-r--r-- | templates/watch/watch.html | 19 | ||||
| -rw-r--r-- | watch/views.py | 4 |
2 files changed, 21 insertions, 2 deletions
diff --git a/templates/watch/watch.html b/templates/watch/watch.html index 0a48f79..37c766a 100644 --- a/templates/watch/watch.html +++ b/templates/watch/watch.html @@ -857,6 +857,25 @@ document.getElementById('skip-buttons').remove(); mediaProviderElememt.appendChild(skipButtons); }); + + const storedQuality = JSON.parse(window.localStorage.getItem('quality')); + const storedAutoQuality = window.localStorage.getItem('autoQuality') === 'true'; + player.qualities.addEventListener('add', (event) => { + const quality = event.detail; + if (storedQuality && quality.height === storedQuality.height && !storedAutoQuality) { + quality.selected = true; + } + }); + + player.qualities.addEventListener('change', (event) => { + const quality = event.detail; + window.localStorage.setItem('quality', JSON.stringify(quality.current)); + }); + + const { autoQuality } = player.state; + player.subscribe(({ autoQuality }) => { + window.localStorage.setItem('autoQuality', autoQuality); + }); player.addEventListener('time-update', (event) => { const currentTime = event.detail.currentTime; diff --git a/watch/views.py b/watch/views.py index 5e8ce29..7d3b981 100644 --- a/watch/views.py +++ b/watch/views.py @@ -94,7 +94,7 @@ def watch(request, anime_id, episode=None): episode_data = response.json() # if no captions are present and the mode is dub, and ingrain_sub_subtitles_in_dub is true, then fetch the sub track - if not any(t["kind"] == "captions" for t in episode_data["tracks"]) and mode == "dub" and request.user.preferences.ingrain_sub_subtitles_in_dub: + if "tracks" in episode_data and not any(t["kind"] == "captions" for t in episode_data["tracks"]) and mode == "dub" and request.user.preferences.ingrain_sub_subtitles_in_dub: base_url = f"{os.getenv("ZORO_URL")}/anime/episode-srcs?id={episode_d["episodeId"]}?server&category=sub" response = requests.get(base_url).json() captions = [t for t in response["tracks"] if t["kind"] == "captions"] @@ -116,7 +116,7 @@ def watch(request, anime_id, episode=None): "episode_data": episode_data, "current_episode": episode, "current_episode_data": current_episode_data, - "stream_url": episode_data["sources"][0]["url"] if episode_data else None, + "stream_url": episode_data["sources"][0]["url"] if episode_data and "sources" in episode_data else None, "anime_id": anime_id, "current_episode_name": current_episode_name, "anime_history": anime_history, |
