ThaUnknown / miru

Bittorrent streaming software for cats. Stream anime torrents, real-time with no waiting for downloads.
https://miru.watch
GNU General Public License v3.0
2.18k stars 125 forks source link

[Feature] Episode Progress Tracking and Resume #409

Closed michielcx closed 5 months ago

michielcx commented 6 months ago

This pull request introduces a new feature that enhances user experience by allowing them to continue watching an episode from where they left off.

Progress of each episode is stored in IndexedDB using Dexie.js. The progress is saved every second, so even when the application closes unexpectedly, the progress is remembered. Additionally the episode progress is displayed on Card components using halfmoon's progress bar and kept automatically up-to-date with Dexie's liveQuery.

I made this for myself, but I can imagine others like this feature.

ThaUnknown commented 6 months ago

I don't fuck with your description as it looks AI generated as fuck

I fuck with this code tho, a lot, it's clean, but you really dont need to use dexie.js, localstorage should be more than enough, maybe even consider using cache store so it times out old progress for you? it's definitely not a needed dependency

Media can fail to resolve, you shouldn't track progress when that happens: https://github.com/ThaUnknown/miru/blob/master/common/modules/animeresolver.js#L206 the code for this isn't clean so read at your own risk lol

Do you handle moments when there's no file media? that can sometimes happen when a person plays a file called myvideo.mkv Miru won't resolve what media it is, and all the metadata for the now playing media will either use old media, or no media at all

the currently media code is so scuffed it's not even funny, so I'm not sure myself what happens, I haven't time to re-write it

ThaUnknown commented 6 months ago

additionally I considered using anilist anime notes, see notes under medialist: https://anilist.github.io/ApiV2-GraphQL-Docs

this would solve the entire "how to save this locally", and also show data across devices which is important

I thought of using 3y3 encoding, this would allow to append data to notes [if the user already has their own] without overriding it, while also making sure it doesn't impact anilist's UI since it's not visible

michielcx commented 6 months ago

Alright Dexie.js is gone, it works with local storage now. I guess cache storage could have worked too but that kind of focuses on caching requests and responses so I think local storage is better suited. Though instead of using expiry the local storage is limited to the latest 1000 episodes (~0.12MB).

I don't know how to play a local file like myvideo.mkv so I haven't tested it. But it compares current.media and media's id and episode to make sure they're the same and truthy. I am guessing that solves some of those problems.

We could make a background task that syncs the changes from local storage to anilist, but that's a future feature I guess?

Here are some screenshots of the progress bar, mind you I am no designer, so feel free to make it look better:

Episode Card:

1

Episode Card (hovered):

2

Small Card:

3

Small Card (hovered):

4

Episode List:

5

Let me know if there's something else

ThaUnknown commented 6 months ago

hover cards and small card looks bad, I probably wouldn't keep that

ThaUnknown commented 6 months ago

also I've noticed your commits use a different email than the account that's the author of this PR, I assume because you don't want torrent related things linked to your main account, feel free to address that if it's an issue, the PR can be 1 commit if you override/squash it, I don't mind