maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   OS2008 / Maemo 4 / Chinook - Diablo (https://talk.maemo.org/forumdisplay.php?f=29)
-   -   Youtube download script (https://talk.maemo.org/showthread.php?t=84669)

auouymous 2012-06-03 22:41

Youtube download script
 
Moving this out of the mYTube thread...

Here is a complete script to download and play youtube videos that have been copied to the clipboard. Read the REQUIRED and USAGE sections in the script for more details.

http://asui.garage.maemo.org/_download/yt


.

Addison 2012-06-04 03:48

Re: Youtube download script
 
Thank you so much auouymous.

It works almost perfect for me. :)

There are still some times when it will fire up playing the wrong video, but that's about it.

A few things to note.

There was talk about immediately deleting a video in the script once it's finished playing... Not a good idea.

My memory card would constantly corrupt this way for some reason. I'm not sure why.

Besides, if something is good, I'd rather move it to a Favorites folder anyway.

The new script to stop a current download is spot on now. :)

I did add this to the end of the kill youtube script just to clean up the memory card at the same time.

rm /media/mmc1/Videos/*.*

I no longer have to keep checking inside the Videos folder to see what's going on anymore. All the weirdness has completely stopped.

It would be neat if there was a simple way to like a video and have it moved to a Saved or Favorites folder.

Also perhaps a way to resume a download if something ever happened while downloading.

Lastly, for those really long vids, a way to resume watching it at a certain point rather than holding the fast forward key.

I guess there's no timestamp of where you left off if the video is still downloading.

Overall, this is amazing though and probably my most used activity while on the tablet these days.

Thanks again for breathing much needed life into this auouymous.

I absolutely love these scripts. :)

auouymous 2012-06-04 05:54

Re: Youtube download script
 
New version available.

It now queries the video name from youtube-dl-x and uses that to launch mplayer. That should fix the problem with it not playing the correct video.

The new yt clean command removes all videos in the download directory. This command invokes the kill option before removing videos.

I removed the keep option since mplayer probably terminates if it reaches the end of the video while it is still downloading. If it doesn terminate then the video would be deleted while youtube-dl-x is still downloading it. The file should be recreated but it could have been causing corruption. @Addison: do you have problems with the video not downloading fast enough and mplayer terminates before playing all of it?

The new yt save moves an already download video (URL must be in clipboard) to a saved video directory.




Quote:

Originally Posted by Addison (Post 1217072)
Also perhaps a way to resume a download if something ever happened while downloading.

Nope. Unless youtube-dl-x does it.


Quote:

Originally Posted by Addison (Post 1217072)
Lastly, for those really long vids, a way to resume watching it at a certain point rather than holding the fast forward key.

Nope.


Quote:

Originally Posted by Addison (Post 1217072)
I guess there's no timestamp of where you left off if the video is still downloading.

Eh?

Addison 2012-06-04 06:17

Re: Youtube download script
 
Sweet!

I'll definitely be grabbing this. :)

To answer your one question, yeah, I think my DSL internet runs on shoe strings and dixie cups.

There will be times I can only get like 40 or so bytes per second.

I'm almost considering the idea of upgrading to dial up. *lol*

So anyway, there are times when Mplayer runs faster than the download itself.

In regards to the timestamp I mentioned...

When you fire up Mplayer and play a video that's fully downloaded, if you stop at some point, there's an option to resume where you left off.

However, if you start this at a time when the video is still downloading, that feature isn't available.

Well, you will always have my thanks for what you have done with this.

It's easily 5 times faster and easier to use than MyTube.

Congrats. :)

Addison 2012-06-04 06:38

Re: Youtube download script
 
Okay. Just 3 things.

They can be ignored though since I'm completely happy already. :)

yt doesn't seem like a good idea.

I've had my memory card corrupted about a dozen times deleting a video immediately after Mplayer shuts down. Perhaps it has something to do with my slow internet speed. Maybe there should be a small, few second delay between these two commands. I'm not sure, I just know that it didn't work for me.

There are times when a download will time out and I'll have to start it all over again. This is kind of a pain for those 100+ meg videos.

I thought for sure youtube-dl-x had an option to resume a download if this were to ever happen.

Lastly, yt save. How do you know that you'll want to save the video before even viewing it>

Seems like that decision would come after.

Anyway, great ideas and concepts and your coding is awesome.

I wish that I had half your talents. :)

EDIT:

Fount it. -c, --continue (resume partially downloaded files)

lma 2012-06-04 08:02

Re: Youtube download script
 
Quote:

Originally Posted by Addison (Post 1217114)
I've had my memory card corrupted about a dozen times deleting a video immediately after Mplayer shuts down.

How do you recover? It may be that the filesystem on the card is still corrupted and deleting a file simply causes the kernel to realise it.

Addison 2012-06-04 23:54

Re: Youtube download script
 
^ I get on my computer, reformat my entire memory card and then fill it back up again with a back up copy that I have on my Windows desktop.

It's kind of annoying. :)

lma 2012-06-05 00:14

Re: Youtube download script
 
That's a bit ... brute force, but should guarantee the filesystem is in good shape. Weird that it gets corrupted reproducibly simply by deleting a file. Does that happen in either SD slot?

Addison 2012-06-05 03:01

Re: Youtube download script
 
Hey lma.

I really don't write to my internal memory card that much since it always seems to be in use.

But yeah, with my external one, I pound it with like 400 megs in files every day it seems like.

One question, since I've been using this YouTube script, there are times when my MMC1 card suddenly vanishes.

I have to pull it out and put it back in again for it to be recognized.

Is there perhaps just a command line to recheck the card?

auouymous 2012-06-05 04:48

Re: Youtube download script
 
Quote:

Originally Posted by Addison (Post 1217114)
yt doesn't seem like a good idea.

The last release no longer removed files unless you ran yt clean. I've updated the USAGE section so it no longer says it removes files.


Quote:

Originally Posted by Addison (Post 1217114)
Lastly, yt save. How do you know that you'll want to save the video before even viewing it

It does come after. You have to use yt get or yt to download the file and while the URL is still in clipboard you type yt save and it moves the already downloaded file. If you download a lot of files at once then yt save won't work unless you copy the URL again.


Quote:

Originally Posted by Addison (Post 1217114)
Fount it. -c, --continue (resume partially downloaded files)

New version uses -c.

Addison 2012-06-05 04:51

Re: Youtube download script
 
Wow!

This is wonderful!

Many thanks again chief. :)

lma 2012-06-05 11:17

Re: Youtube download script
 
Quote:

Originally Posted by Addison (Post 1217620)
One question, since I've been using this YouTube script, there are times when my MMC1 card suddenly vanishes.

I have to pull it out and put it back in again for it to be recognized.

Yeah, it smells like a hardware issue, that's why I asked if you also get it in the other slot. If you swap the two cards around does the problem follow the card or the slot?

Addison 2012-06-05 11:21

Re: Youtube download script
 
I've never once bothered to swap them.

I was going to pick up a 128 gig card this month.

Now that would be a real pain if it ever got corrupted.

My computer only has like 80 megs on it. :(

auouymous 2012-06-05 11:25

Re: Youtube download script
 
Quote:

Originally Posted by Addison (Post 1217815)
I was going to pick up a 128 gig card this month.

Will a 128gig card work in the n8x0? I thought they were limited to 16gig cards.

Addison 2012-06-05 11:28

Re: Youtube download script
 
Somebody tried it and said that it worked.

By the way, I never new that there were so many full, modern, Hollywood movies that can be found on YouTube until today.

So happy. <3

lma 2012-06-05 11:30

Re: Youtube download script
 
Quote:

Originally Posted by auouymous (Post 1217816)
Will a 128gig card work in the n8x0? I thought they were limited to 16gig cards.

That's just what Nokia says is "supported" (ie, what they could test at the time the specs were written). I have a 32GB microSD in my N810 which works fine, and there are several reports of larger SDXC/microSDXC also working (once formatted with a sane filesystem). An N800 can take obscene amounts of storage these days :-)

Addison 2012-06-05 11:45

Re: Youtube download script
 
Quick question.

For something like this...
http://m.youtube.com/watch?gl=US&hl=...&v=RhY0RdDQdro

Is it possible with the -F option to see what all of the formats are available for download and can the tablet even run those with slightly higher quality, even if you had to use Media Player instead?

Addison 2012-06-05 14:02

Re: Youtube download script
 
Using Firefox download helper on my computer, I've seen just the video's title name, medium, 240, 320, 480, 720, and 1080p options for download.

I'm wondering if the tablet can run something higher than the lowest encoding.

I guess I could just find out myself later tonight. :)

auouymous 2012-06-06 04:22

Re: Youtube download script
 
Quote:

Originally Posted by Addison (Post 1217891)
I'm wondering if the tablet can run something higher than the lowest encoding.

I believe the encoder scripts that run on a desktop produce videos of higher quality but the format generated isn't something you can get from youtube. If you download a higher quality video from youtube it will usually have playback issues.

Just setup a little server script on your desktop, have your tablet send a request to it to download a highest quality youtube video, encode for your tablet, scp it over and then send your tablet an email notification. Switch your desktop to Linux and I'll write it for you. ;)

Addison 2012-06-06 04:28

Re: Youtube download script
 
Yeah, I did some testing tonight and almost got 360p to play but it wasn't quite there though. :(

It's weird because I have some videos in mp4 format that are actually a much better quality and have perfect playback.

I'll have to look into what the difference between these are on this.

Addison 2012-06-06 07:00

Re: Youtube download script
 
Well, from the video I posted above:

"360P" download was
640x260
Frame rate 48

"Medium" download was
640x260
Frame rate 24

If it were in .avi format with mp3 audio instead of mp4, "Medium" would probably play quite nicely.

I never did understand why mp4 is used over avi with YouTube.

Not even my Xbox can play that format very well.

Oh well, I think maybe I should look into installing Linux, just for auouymous. :)

auouymous 2012-06-06 07:40

Re: Youtube download script
 
Quote:

Originally Posted by Addison (Post 1218239)
"360P" download was
640x260
Frame rate 48
"Medium" download was
640x260
Frame rate 24

The tablet-encode script uses 400x240 @ 15 frames.


Quote:

Originally Posted by Addison (Post 1218239)
I never did understand why mp4 is used over avi with YouTube.

Maybe because MP4 fixes the problems that AVI has.


Quote:

Originally Posted by Addison (Post 1218239)
Oh well, I think maybe I should look into installing Linux, just for auouymous.

You have it on your tablet, now put it on your desktop. ;)

Addison 2012-06-07 02:58

Re: Youtube download script
 
So I downloaded this video at 720P.
http://m.youtube.com/watch?v=hBYymaN...e_gdata_player

I was able to transcode it to 640x368, at 44100 sample rate for audio.

It looked and sounded good but really wasn't worth the time.

Anyway, I also downloaded it using youtube-dl-x and noticed something.

With the tablet's version, the audio was only at 22050.

I'm not sure how all of the encoding for a video is stored at YouTube, but is it possible to grab the lowest video quality like it does now but also a better audio at the same time in your script?

It seems like the audio should always be a stereo mp3 at a 44100 kHz sample rate, and 128 Kbps bit rate.

Can this be done?

Cheers. :)

Addison 2012-06-07 06:45

Re: Youtube download script
 
Okay, say for this YouTuber...
http://m.youtube.com/user/osirislightandsound

Is it possible to just grab the audio at 44100 kHz, 128 Kbps and not even bother with the video?

Looking through the youtube-dl-x options, it seems like it can only be done after downloading it in full and then doing some post-processing on it afterwards which isn't supported because we don't have ffmeg and ffprobe compiled.

Is this correct?

Thanks ahead as always. :)

auouymous 2012-06-07 06:58

Re: Youtube download script
 
Quote:

Originally Posted by Addison (Post 1218736)
Is it possible to just grab the audio at 44100 kHz, 128 Kbps and not even bother with the video?

I doubt it. If you run youtube-dl with the -F option you can see the available formats for a given video. You can select the format and resultion, not the audio quality, unless they encode different formats with different qualities, try googling for more details on each format ID (the number in far left column).


Quote:

Originally Posted by Addison (Post 1218736)
Looking through the youtube-dl-x options, it seems like it can only be done after downloading it in full and then doing some post-processing on it afterwards which isn't supported because we don't have ffmeg and ffprobe compiled.

Is this correct?

Yes, youtube-dl downloads the video, extracts the audio track and then encodes to mp3.

Addison 2012-06-07 06:59

Re: Youtube download script
 
Yeah, that's what I thought.

Thanks chief!

Addison 2012-06-07 20:19

Re: Youtube download script
 
Well, you know me, always asking questions. *lol*

So for this...
http://m.youtube.com/watch?gl=US&hl=...&v=BQu4PUJ5oA4

To get the quickest and best audio quality, would that be just to download it in 720P format and then play the .mp4 through XMMS?

I tried this and it's showing that the audio is in Variable Bit Rate format so I'm not sure if that is the high, low or medium end for the sound.

Thanks!

auouymous 2012-06-07 23:09

Re: Youtube download script
 
Quote:

Originally Posted by Addison (Post 1219139)
To get the quickest and best audio quality, would that be just to download it in 720P format and then play the .mp4 through XMMS?

Or mplayer using the -novideo parameter.

Addison 2012-06-08 23:15

Re: Youtube download script
 
Hey chief.

Is yt clean working on your end?

If I run it while a video is playing I get

Code:

killall: cannot kill pid 15814: No such process
Terminated

If I run it when mplayer isn't running I get

Code:

You need to specify whom to kill
Either way, the folder doesn't clear.

auouymous 2012-06-08 23:53

Re: Youtube download script
 
Quote:

Originally Posted by Addison (Post 1219690)
Is yt clean working on your end?
Either way, the folder doesn't clear.

It calls yt kill and that was killing the yt clean script so it couldn't empty the directory.

Version 1.3 is now available to fix that and also adds ability to specify URL on command line.

Addison 2012-06-08 23:56

Re: Youtube download script
 
Suweet! :D

shawnjefferson 2012-06-12 03:13

Re: Youtube download script
 
I wanted to try this out, but I can't install xclip, I get an error that the package isn't the right size.

I've used myTube before, but the video doesn't start until the download is totally complete for me, and that takes quite a long time generally. It seems from reading some of the threads (including this one) that viewing should happen as the youtube video is downloading?

Addison 2012-06-12 03:15

Re: Youtube download script
 
Give me a minute to fire up my computer and I'll upload xclip for you. :)

auouymous 2012-06-12 03:22

Re: Youtube download script
 
Quote:

Originally Posted by shawnjefferson (Post 1220755)
I wanted to try this out, but I can't install xclip, I get an error that the package isn't the right size.

Quote:

Originally Posted by Addison (Post 1220756)
Give me a minute to fire up my computer and I'll upload xclip for you. :)

No need to upload anything, xclip is already available online. Just read the REQUIRED section in the script as mentioned by the first post.

Addison 2012-06-12 03:25

Re: Youtube download script
 
^ Okay.

I think I also remember seeing it in the Application Catalog as well, maybe under Maemo Extras, I can't remember.

Also, Shawn, yeah, it will begin playing the video 30 seconds after it begins downloading but you can change that time depending upon your internet speed.

auouymous 2012-06-12 03:30

Re: Youtube download script
 
Quote:

Originally Posted by Addison (Post 1220758)
I think I also remember seeing it in the Application Catalog as well, maybe under Maemo Extras, I can't remember.

The version in the repository is either corrupt or exploited. That is why I downloaded the source, built a new binary and put it up on the ASUI site. :)

--

BTW, anyone happen to know why the forum unsubscribes me after I post in a thread?

Addison 2012-06-12 03:32

Re: Youtube download script
 
Quote:

BTW, anyone happen to know why the forum unsubscribes me after I post in a thread?
No clue.

I've got about 30 subscriptions and not once have I lost any of them by posting in a thread.

Very weird.

shawnjefferson 2012-06-12 04:15

Re: Youtube download script
 
When all else fails, RTFM! :) Got it working. Thanks for that!

I noticed on my system that running this under Busybox, mplayer doesn't launch properly. Running under bash works fine.

Addison 2012-06-12 17:32

Re: Youtube download script
 
Quote:

BTW, anyone happen to know why the forum unsubscribes me after I post in a thread?
I did get this message in my email earlier....

Quote:

There may also be other replies, but you will not receive any more notifications until you visit the forum again.
I can't recall ever seeing this before.

Perhaps there are some new coding changes here at TMO.

lma 2012-06-12 18:01

Re: Youtube download script
 
My notifications always had that, and it was even true until a few months ago (I think when the forum subscriptions went live). Now I get notifications for every post regardless of visiting here or not.


All times are GMT. The time now is 00:31.

vBulletin® Version 3.8.8