wader / goutubedl

Go wrapper for youtube-dl and yt-dlp
https://pkg.go.dev/github.com/wader/goutubedl?tab=doc
MIT License
86 stars 26 forks source link

DownloadSections option #157

Closed ar2rworld closed 1 year ago

ar2rworld commented 1 year ago

--download-sections support

ar2rworld commented 1 year ago

but it requires ffmpeg installed

wader commented 1 year ago

Hey, looks good and i think ffmpeg is more or less required anyway. Wonder if we want some kind if test?

Also fixes #151 i think

ar2rworld commented 1 year ago

Hey @wader, check this one out. And I am not sure if

if ydlResult.Options.DownloadSections != "*0:0-0:5" {
  t.Errorf("failed to setup --download-sections")
}

is required?

wader commented 1 year ago

Probably good idea to check that the option "round-trips" so leave it i think. I guess one could check the duration of the output but would require ffmpeg etc. ...but i notice now that ffmpeg is not installed in the Dockerfile when running tests, so how does this work? ffmpeg not needed by yt-dlp for this or it behaves differently?

wader commented 1 year ago

Hi again, took a deeper look and found some issues:

root@44453646f6dd:/Users/wader/src/goutubedl# yt-dlp -o - -f sb2 --download-sections '*0:0-0:5' 'https://www.youtube.com/watch?v=OyuL5biOQ94' > test
[youtube] Extracting URL: https://www.youtube.com/watch?v=OyuL5biOQ94
[youtube] OyuL5biOQ94: Downloading webpage
WARNING: [youtube] unable to extract initial player response; please report this issue on  https://github.com/yt-dlp/yt-dlp/issues?q= , filling out the appropriate issue template. Confirm you are on the latest version using  yt-dlp -U
[youtube] OyuL5biOQ94: Downloading ios player API JSON
[youtube] OyuL5biOQ94: Downloading android player API JSON
[youtube] OyuL5biOQ94: Downloading iframe API JS
[youtube] OyuL5biOQ94: Downloading player c153b631
[youtube] OyuL5biOQ94: Downloading web player API JSON
[youtube] OyuL5biOQ94: Downloading m3u8 information
WARNING: [youtube] unable to extract yt initial data; please report this issue on  https://github.com/yt-dlp/yt-dlp/issues?q= , filling out the appropriate issue template. Confirm you are on the latest version using  yt-dlp -U
WARNING: [youtube] Incomplete data received in embedded initial data; re-fetching using API.
[youtube] OyuL5biOQ94: Downloading initial data API JSON
[info] OyuL5biOQ94: Downloading 1 format(s): sb2
[info] OyuL5biOQ94: Downloading 1 time ranges: 0.0-5.0
ERROR: You have requested downloading the video partially, but ffmpeg is not installed. Aborting

I tried installing ffmpeg and change format then --download-sections seem to work fine. So maybe we should install it and do some checks?

ar2rworld commented 1 year ago

added ffmpeg to the Dockerfile and added exec.Command check for FFmpeg in the test

wader commented 1 year ago

ci fails on installing ffmpeg, missing && i think. there is some tips how to build and run tests here https://github.com/wader/goutubedl#development

ar2rworld commented 1 year ago

thanks that was helpful, i think it is good to go?

ar2rworld commented 1 year ago

looks very messy, what do you think?

wader commented 1 year ago

yeah a bit messy but maybe ok?

ar2rworld commented 1 year ago

how can I improve it?

wader commented 1 year ago

I guess it could be refactored to some kind of ffprobe/get value function but maybe can wait until another test needs it

wader commented 1 year ago

Thanks!

ar2rworld commented 1 year ago

Thanks for your support)