lbryio / ytsync

An overly complex tool to mirror youtube content to LBRY
https://lbry.com/youtube
MIT License
42 stars 17 forks source link

Local ytsync #112

Open lyoshenka opened 3 years ago

lyoshenka commented 3 years ago

We'd like to let users run their own ytsync process to sync their youtube channel to LBRY without relying on the Odysee service.

Assumptions

Corner cases

Iterations

v1 - Sync a single video

Get local sync working for a single video. Don't worry about any corner cases yet.

Inputs: youtube video ID, LBRY channel ID, path to temp dir Outputs: a video is published to the LBRY channel

v2 - Identify synced videos

Go through a youtube channel and figure out which videos have already been synced to a LBRY channel

If a video has already been synced (by Odysee or by a previous run of local ytsync), it should never be synced again. Local ytsync should detect that, or in the worst case should make a strong guess or get a human involved.

Inputs: youtube channel ID, LBRY channel ID Outputs: a list of youtube video IDs that have not been synced yet

There are several options:

In addition we may want to update claim protobuf so you can explicitly tag videos as having been synced from youtube. This would be the best way to identify synced content in the future.

In any case, its a good idea to locally cache what videos have been synced successfully.

v3 - Continuous sync

v4 - Hardening and optimization

v5 - Contribute to Odysee

Figure out how to help odysee with centralized ytsync. Simplest form is detecting new videos from other syncing channels. Harder is participating in sync for those channels.

v6 - Cluster

Run a local cluster of ytsync nodes that split the work of syncing content. They should share a queue and data store, keep lists of synced content up to date, etc.

Notes on Odysee API endpoints

One gotcha is duplicate syncs (race condition). Make sure you don't start syncing something at the same time that odysee starts syncing it. Maybe need a way to mark a sync as in-progress.

Another gotcha is what happens if you start syncing a video but Odysee doesn't know about this video yet (maybe notification didn't arrive or was missed). How can you mark it as synced? Maybe once you turn sync off, you're just taking responsibility for it?

pseudoscalar commented 3 years ago

Note for beyond v1: Check for YouTube API request limits and halt sync if gone over. Getting the release date right is pretty important, and any failure to determine it should probably stop the sync.