Download video to sync to local cache #113

Open
pseudoscalar wants to merge 7 commits from pseudoscalar/issue/112/v1 into local
pseudoscalar commented 2021-10-14 20:07:35 +02:00 (Migrated from github.com)

Partial completion of v1 of issue #112. Drafting this PR for discussion.

Partial completion of v1 of issue #112. Drafting this PR for discussion.
lyoshenka (Migrated from github.com) reviewed 2021-10-14 21:42:24 +02:00
lyoshenka (Migrated from github.com) commented 2021-10-14 21:42:24 +02:00

i recommend os.ReadFile() to read the file in one go

i recommend os.ReadFile() to read the file in one go
pseudoscalar commented 2021-10-25 23:30:51 +02:00 (Migrated from github.com)

Posting some work before I get too far off into the weeds. There are some comments about improvements that could be made to the go jsonrpc client, and stuff I still need to do for the upload. This is due for a refactor, I just wanted to get the whole process out into code before figuring out how to organize it.

Posting some work before I get too far off into the weeds. There are some comments about improvements that could be made to the go jsonrpc client, and stuff I still need to do for the upload. This is due for a refactor, I just wanted to get the whole process out into code before figuring out how to organize it.
lyoshenka (Migrated from github.com) reviewed 2021-11-05 21:42:52 +01:00
lyoshenka (Migrated from github.com) commented 2021-11-05 21:32:31 +01:00

id call this something other than done to make it clear its a channel that lets you know when the video is done reflecting

id call this something other than `done` to make it clear its a channel that lets you know when the video is done reflecting
lyoshenka (Migrated from github.com) commented 2021-11-05 21:37:50 +01:00

minor nit, but doesn't this potentially make the description longer than the max length?

minor nit, but doesn't this potentially make the description longer than the max length?
@ -22,0 +86,4 @@
videoID := args[0]
log.Debugf("Running sync for video ID %s", videoID)
lyoshenka (Migrated from github.com) commented 2021-11-05 21:31:22 +01:00

prolly need to make sure this exists

prolly need to make sure this exists
lyoshenka (Migrated from github.com) commented 2021-11-05 21:35:00 +01:00

if this is an error (or an unexpected thing), it should prolly send an error to done, right?

if this is an error (or an unexpected thing), it should prolly send an error to `done`, right?
@ -0,0 +18,4 @@
func NewYouTubeAPIVideoEnricher(apiKey string) (*YouTubeAPIVideoEnricher) {
enricher := YouTubeAPIVideoEnricher{
api: NewYouTubeAPI(apiKey),
lyoshenka (Migrated from github.com) commented 2021-11-05 21:39:51 +01:00

so the best way to get the release time was via the api? if so, can you include instructions in your PR on what a user would need to do to get an api key? we'd also want to add handling in a later version for exceeding api limits

so the best way to get the release time was via the api? if so, can you include instructions in your PR on what a user would need to do to get an api key? we'd also want to add handling in a later version for exceeding api limits
@ -0,0 +59,4 @@
FullLocalPath: videoPath,
}
for _, enricher := range s.enrichers {
lyoshenka (Migrated from github.com) commented 2021-11-05 21:42:48 +01:00

this is an interesting design. what other enrichers did you envision?

this is an interesting design. what other enrichers did you envision?
pseudoscalar (Migrated from github.com) reviewed 2021-11-08 16:37:40 +01:00
@ -22,0 +86,4 @@
videoID := args[0]
log.Debugf("Running sync for video ID %s", videoID)
pseudoscalar (Migrated from github.com) commented 2021-11-08 16:37:40 +01:00

This should be guaranteed by cobra.ExactArgs(1), but I can a check and error here too.

This should be guaranteed by `cobra.ExactArgs(1)`, but I can a check and error here too.
pseudoscalar (Migrated from github.com) reviewed 2021-11-08 16:44:35 +01:00
pseudoscalar (Migrated from github.com) commented 2021-11-08 16:44:35 +01:00

This was mostly ripped from getAbbrevDescription in sources/youtubeVideo.go. I didn't know exactly where the value of 2800 came from, so I just assumed the logic was correct. If it is supposed to be a limit on the total description length, I'll fix this.

This was mostly ripped from `getAbbrevDescription` in sources/youtubeVideo.go. I didn't know exactly where the value of 2800 came from, so I just assumed the logic was correct. If it is supposed to be a limit on the total description length, I'll fix this.
pseudoscalar (Migrated from github.com) reviewed 2021-11-08 16:47:59 +01:00
@ -0,0 +18,4 @@
func NewYouTubeAPIVideoEnricher(apiKey string) (*YouTubeAPIVideoEnricher) {
enricher := YouTubeAPIVideoEnricher{
api: NewYouTubeAPI(apiKey),
pseudoscalar (Migrated from github.com) commented 2021-11-08 16:47:59 +01:00

This was the simplest and most direct way, and the API limits seem like more than enough for the single channel use-case (except on initial channel sync). Should I add the instructions to the local/readme.md?

This was the simplest and most direct way, and the API limits seem like more than enough for the single channel use-case (except on initial channel sync). Should I add the instructions to the local/readme.md?
pseudoscalar (Migrated from github.com) reviewed 2021-11-08 17:04:52 +01:00
@ -0,0 +59,4 @@
FullLocalPath: videoPath,
}
for _, enricher := range s.enrichers {
pseudoscalar (Migrated from github.com) commented 2021-11-08 17:04:52 +01:00

This mainly came out of trying to accommodate easy switching between methods of getting release date and also allowing for fallback to multiple methods. The other methods in mind were things like the odysee API, multiple YouTube API keys, a future update to yt-dlp that might provide it, web scraping (although I don't think this would currently work as only the date is provided), or some 3rd party metadata provider. In the single video use-case, there could even be an enricher that just supplies values specified on the command line.

The design here is meant to put together a list of enrichers based on command line options. The enrichers will then take turns trying fill-in the missing video metadata (although right now, it is only trying to fill-in release date)

This mainly came out of trying to accommodate easy switching between methods of getting release date and also allowing for fallback to multiple methods. The other methods in mind were things like the odysee API, multiple YouTube API keys, a future update to yt-dlp that might provide it, web scraping (although I don't think this would currently work as only the date is provided), or some 3rd party metadata provider. In the single video use-case, there could even be an enricher that just supplies values specified on the command line. The design here is meant to put together a list of enrichers based on command line options. The enrichers will then take turns trying fill-in the missing video metadata (although right now, it is only trying to fill-in release date)
pseudoscalar (Migrated from github.com) reviewed 2021-11-08 17:17:49 +01:00
pseudoscalar (Migrated from github.com) commented 2021-11-08 17:17:49 +01:00

The thinking was that this may be intentional since it is driven by lbrynet settings. I could turn this into an error if that case is unlikely. I could also add a command line flag to indicate that streams won't be reflected.

The thinking was that this may be intentional since it is driven by lbrynet settings. I could turn this into an error if that case is unlikely. I could also add a command line flag to indicate that streams won't be reflected.
lyoshenka (Migrated from github.com) reviewed 2021-11-11 23:09:58 +01:00
@ -22,0 +86,4 @@
videoID := args[0]
log.Debugf("Running sync for video ID %s", videoID)
lyoshenka (Migrated from github.com) commented 2021-11-11 23:09:58 +01:00

you're right, i just didnt notice that

you're right, i just didnt notice that
lyoshenka (Migrated from github.com) reviewed 2021-11-11 23:11:09 +01:00
lyoshenka (Migrated from github.com) commented 2021-11-11 23:11:09 +01:00

yea id either make it an option or just assume that all streams will be reflected. option is better but more work

yea id either make it an option or just assume that all streams will be reflected. option is better but more work
lyoshenka (Migrated from github.com) reviewed 2021-11-11 23:12:04 +01:00
lyoshenka (Migrated from github.com) commented 2021-11-11 23:12:04 +01:00

i think that's an estimate of how long the description can get before we hit the max claim size limit. id still fix it so the math is right though :-)

i think that's an estimate of how long the description can get before we hit the max claim size limit. id still fix it so the math is right though :-)
lyoshenka (Migrated from github.com) reviewed 2021-11-11 23:12:26 +01:00
@ -0,0 +18,4 @@
func NewYouTubeAPIVideoEnricher(apiKey string) (*YouTubeAPIVideoEnricher) {
enricher := YouTubeAPIVideoEnricher{
api: NewYouTubeAPI(apiKey),
lyoshenka (Migrated from github.com) commented 2021-11-11 23:12:26 +01:00

yea

yea
lyoshenka (Migrated from github.com) reviewed 2021-11-11 23:13:54 +01:00
@ -0,0 +18,4 @@
func NewYouTubeAPIVideoEnricher(apiKey string) (*YouTubeAPIVideoEnricher) {
enricher := YouTubeAPIVideoEnricher{
api: NewYouTubeAPI(apiKey),
lyoshenka (Migrated from github.com) commented 2021-11-11 23:13:54 +01:00

maybe add a note to the issue to give the user a good error message if the api runs out of credits, and stop the sync. getting the release time right is fairly important so we don't want to guess or leave it empty. this could go under v4

maybe add a note to the issue to give the user a good error message if the api runs out of credits, and stop the sync. getting the release time right is fairly important so we don't want to guess or leave it empty. this could go under v4
lyoshenka (Migrated from github.com) reviewed 2021-11-11 23:14:24 +01:00
@ -0,0 +59,4 @@
FullLocalPath: videoPath,
}
for _, enricher := range s.enrichers {
lyoshenka (Migrated from github.com) commented 2021-11-11 23:14:24 +01:00

👍

:+1:
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin pseudoscalar/issue/112/v1:pseudoscalar/issue/112/v1
git checkout pseudoscalar/issue/112/v1

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git checkout local
git merge --no-ff pseudoscalar/issue/112/v1
git checkout pseudoscalar/issue/112/v1
git rebase local
git checkout local
git merge --ff-only pseudoscalar/issue/112/v1
git checkout pseudoscalar/issue/112/v1
git rebase local
git checkout local
git merge --no-ff pseudoscalar/issue/112/v1
git checkout local
git merge --squash pseudoscalar/issue/112/v1
git checkout local
git merge --ff-only pseudoscalar/issue/112/v1
git checkout local
git merge pseudoscalar/issue/112/v1
git push origin local
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: LBRYCommunity/ytsync#113
No description provided.