Page 1 of 1

How to donwload from a website to a USB ...?

Posted: Sat Jun 18, 2022 5:30 am
by keos
Hello,

Yesterday I had to do a very large download from youtube to the operating system because I didn't know how to directly download all the material/data to a USB, the system filled up, 100% ... -- yes, after that I moved it to the usb, but I don't think I could complete it all.

What command (yt-dlp) should I use to make the download go directly to the USB and not to the system?.

Thanks for any information.

Re: How to donwload from a website to a USB ...?

Posted: Sat Jun 18, 2022 6:05 am
by baldyeti
'yt-dlp --help' reveals one can use the '-P' flag (uppercase "P"), e.g:

Code: Select all

yt-dlp -f bestaudio -P /destination/path/ http://some-url/some-id

Re: How to donwload from a website to a USB ...?

Posted: Sat Jun 18, 2022 7:51 am
by Stuart_M
keos wrote: Sat Jun 18, 2022 5:30 am ... What command (yt-dlp) should I use to make the download go directly to the USB and not to the system?.
I know you asked for a yt-dlp command to use but you may like this way that does NOT use a yt-dlp command to save in a specific directory, and will produce the same results (and is easier, in my opinion). All you need to do is change the working directory of the terminal you are using to run the yt-dlp command.

There are a couple ways of changing the working directory of the terminal.
  • Use cd dir1/dir2/dir3... (cd = Change Directory) to change the working directory and then run your normal yt-dlp command.
OR
  • In Thunar,
    Go to the directory you want the yt-dlp file to be saved.
    Right-click on that directory (in this case it would be your USB drive).
    Select "Open Terminal Here".

    The terminal will then open in the working directory that you want to download/save the file in. All you then have to do is just run your normal yt-dlp command.

Re: How to donwload from a website to a USB ...?

Posted: Sat Jun 18, 2022 9:02 am
by keos
I'm doing something wrong.

I don't understand the command, by 'some-id' I understand it to be the destination, so I type 'usb-data' (the name of the usb I have) but I get an error.

Code: Select all

keos@kaos:~
$ yt-dlp -f bestaudio -P /destination/path/ https://www.youtube.com/watch?v=TNf2Ye_mduY/USB-DATA
[youtube] TNf2Ye_mduY: Downloading webpage
[youtube] TNf2Ye_mduY: Downloading android player API JSON
[info] TNf2Ye_mduY: Downloading 1 format(s): 251
ERROR: unable to create directory [Errno 13] Permission denied: '/destination'
keos@kaos:~
$ 

Re: How to donwload from a website to a USB ...?

Posted: Sat Jun 18, 2022 9:11 am
by baldyeti
You need to provide the path to your target folder. For a removable USB stick, typically someting that starts with /media/$USER/...

Re: How to donwload from a website to a USB ...?

Posted: Sat Jun 18, 2022 9:27 am
by keos
I'm sorry but I still don't understand.

I think you indicate that I should do it this way:

Code: Select all

keos@kaos:~
$ yt-dlp -f bestaudio -P /destination/path/ https://www.youtube.com/watch?v=TNf2Ye_mduY/media/$keos/
[youtube] TNf2Ye_mduY: Downloading webpage
[youtube] TNf2Ye_mduY: Downloading android player API JSON
[info] TNf2Ye_mduY: Downloading 1 format(s): 251
ERROR: unable to create directory [Errno 13] Permission denied: '/destination'
keos@kaos:~
$ 

Re: How to donwload from a website to a USB ...?

Posted: Sat Jun 18, 2022 9:29 am
by Neil
That is correct, except you must change the /destination/path/ to the actual path to your USB device.
The method Stuart_M suggests may be easier to understand.

Re: How to donwload from a website to a USB ...?

Posted: Sat Jun 18, 2022 9:31 am
by keos

Code: Select all

keos@kaos:~
$ yt-dlp -f bestaudio -P /media/keos/ https://www.youtube.com/watch?v=TNf2Ye_mduY/USB-DATA
[youtube] TNf2Ye_mduY: Downloading webpage
[youtube] TNf2Ye_mduY: Downloading android player API JSON
[info] TNf2Ye_mduY: Downloading 1 format(s): 251
[download] Got file access error. Retrying (attempt 1 of 10) ...
[download] Got file access error. Retrying (attempt 2 of 10) ...
[download] Got file access error. Retrying (attempt 3 of 10) ...
[download] Got file access error. Retrying (attempt 4 of 10) ...
[download] Got file access error. Retrying (attempt 5 of 10) ...
[download] Got file access error. Retrying (attempt 6 of 10) ...
[download] Got file access error. Retrying (attempt 7 of 10) ...
[download] Got file access error. Retrying (attempt 8 of 10) ...
[download] Got file access error. Retrying (attempt 9 of 10) ...
[download] Got file access error. Retrying (attempt 10 of 10) ...
ERROR: unable to open for writing: [Errno 13] Permission denied: '/media/keos/Kim Walker-Smith – Make Room (Official Live Video) [TNf2Ye_mduY].webm.part'

keos@kaos:~
$ 

Re: How to donwload from a website to a USB ...?

Posted: Sat Jun 18, 2022 9:32 am
by keos
If someone could please give me an example perhaps ...

EDIT:

I tried now in this way, it works, but i got just the audio, it is a video:

Code: Select all

keos@kaos:~
$ yt-dlp -f bestaudio -P /media/keos/USB-DATA/ https://www.youtube.com/watch?v=TNf2Ye_mduY/media/keos/USB-DATA/
[youtube] TNf2Ye_mduY: Downloading webpage
[youtube] TNf2Ye_mduY: Downloading android player API JSON
[info] TNf2Ye_mduY: Downloading 1 format(s): 251
[download] Destination: /media/keos/USB-DATA/Kim Walker-Smith – Make Room (Official Live Video) [TNf2Ye_mduY].webm
[download] 100% of 12.70MiB in 00:05
keos@kaos:~
$ 

EDIT:

I tried now 'this' ... and i got video and audio but with a warning saying that "it is often not the best option":

Code: Select all

keos@kaos:~
$ yt-dlp -f best -P /media/keos/USB-DATA/ https://www.youtube.com/watch?v=TNf2Ye_mduY/media/keos/USB-DATA/
WARNING: "-f best" selects the best pre-merged format which is often not the best option.
         To let yt-dlp download and merge the best available formats, simply do not pass any format selection.
         If you know what you are doing and want only the best pre-merged format, use "-f b" instead to suppress this warning
[youtube] TNf2Ye_mduY: Downloading webpage
[youtube] TNf2Ye_mduY: Downloading android player API JSON
[info] TNf2Ye_mduY: Downloading 1 format(s): 22
[download] Destination: /media/keos/USB-DATA/Kim Walker-Smith – Make Room (Official Live Video) [TNf2Ye_mduY].mp4
[download] 100% of 79.98MiB in 00:16
keos@kaos:~
$ 

Re: How to donwload from a website to a USB ...?

Posted: Sat Jun 18, 2022 9:54 am
by Stuart_M
The reason you only get the audio is because you have downloaded only the audio portion by using the -f bestaudio option. Omit that portion and it should be fine.

The command would then look like this:

Code: Select all

yt-dlp -P /media/keos/USB-DATA/ https://www.youtube.com/watch?v=TNf2Ye_mduY/media/keos/USB-DATA/

P.S. I still think running the command with the terminal's working directory where you want the file saved is the easiest and fastest way (my post #3).

Re: How to donwload from a website to a USB ...?

Posted: Sat Jun 18, 2022 10:02 am
by Stuart_M
keos wrote: Sat Jun 18, 2022 9:32 am
I tried now 'this' ... and i got video and audio but with a warning saying that "it is often not the best option":

Code: Select all

keos@kaos:~
$ yt-dlp -f best -P /media/keos/USB-DATA/ https://www.youtube.com/watch?v=TNf2Ye_mduY/media/keos/USB-DATA/
...
The answer is to eliminate -f best from the command you are using. The correct command is shown in my Post #10 above.

When the -f option is used you are telling yt-dlp to use a format other than the default, which is the format that gives the best quality. Without the -f option yt-dlp will automatically select the best video and audio. From everything you have posted in this thread there is no reason that you would need or want that option at this time.

If something other than the "best" quality is desired then force that by using the -f (format) option.

Re: How to donwload from a website to a USB ...?

Posted: Sat Jun 18, 2022 10:13 am
by baldyeti
Basically what i meant was: just use yt-dlp like you otherwise would, just add the -P flag and its argument (your target directory, underneath your USB mount point)

Or Stuart's suggestion might be simpler: cd to your target folder before invoking yt-dlp

Re: How to donwload from a website to a USB ...?  [Solved]

Posted: Sat Jun 18, 2022 10:33 am
by keos
    I have tried again ... this time, I just added '-P' as you indicate and it worked correctly

    -- I prefer this command because I rarely download large files from youtube and I don't want to 'permanently' modify Thunar, it would be inconvenient ... every time I want to download something I have to ...

    Finally this is what I did:

    Code: Select all

    keos@kaos:~
    $ yt-dlp -P /media/keos/USB-DATA/ https://www.youtube.com/watch?v=TNf2Ye_mduY/media/keos/USB-DATA/
    [youtube] TNf2Ye_mduY: Downloading webpage
    [youtube] TNf2Ye_mduY: Downloading android player API JSON
    [info] TNf2Ye_mduY: Downloading 1 format(s): 313+251
    [download] Destination: /media/keos/USB-DATA/Kim Walker-Smith – Make Room (Official Live Video) [TNf2Ye_mduY].f313.webm
    [download] 100% of 876.37MiB in 03:03
    [download] Destination: /media/keos/USB-DATA/Kim Walker-Smith – Make Room (Official Live Video) [TNf2Ye_mduY].f251.webm
    [download] 100% of 12.70MiB in 00:06
    [Merger] Merging formats into "/media/keos/USB-DATA/Kim Walker-Smith – Make Room (Official Live Video) [TNf2Ye_mduY].webm"
    Deleting original file /media/keos/USB-DATA/Kim Walker-Smith – Make Room (Official Live Video) [TNf2Ye_mduY].f251.webm (pass -k to keep)
    Deleting original file /media/keos/USB-DATA/Kim Walker-Smith – Make Room (Official Live Video) [TNf2Ye_mduY].f313.webm (pass -k to keep)
    keos@kaos:~
    $
    Thank you very much to both of you :happy:

    Re: How to donwload from a website to a USB ...?

    Posted: Sat Jun 18, 2022 10:54 am
    by towwire
    You can install 'youtubedl-gui' which has a Browse.. button that you set or change where you want the save your file.