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)

Addison 2012-06-17 07:29

Re: Youtube download script
 
Quote:

New version uses -c.
How does one use this feature?

It's not explained in your notes.

auouymous 2012-06-17 07:47

Re: Youtube download script
 
Quote:

Originally Posted by Addison (Post 1223056)
How does one use this feature? It's not explained in your notes.

You don't do anything, it is part of the youtube-dl commands in the script so it should automatically resume. Unless of course that feature requires .part files which the script turns off. I did forget to put the -c on the get command so 1.3.1 is now available to fix that (assuming -c even works without parts). Let me know if it still isn't resuming.

Addison 2012-06-17 07:51

Re: Youtube download script
 
I once did it by command line and it did work. :)

Addison 2012-06-18 09:20

Re: Youtube download script
 
Is there any possible trick to resume playback of a large video in .flv format?

Holding the fast forward key for 10 plus minutes just to get back to where I left off in a vid is such a pain.

I've messed with the -ss option as well as /home/user/.mplayer/video.position with no luck.

Addison 2012-06-24 06:12

Re: Youtube download script
 
Hi auouymous.

I added one little, small time saver to your coding and just felt like posting it.

matchbox-remote -next

I put this on the first line.

Since I'm always using the Tear web browser with this and I also have your scripts on the Desktop with Personal Launcher, it's just an easier way to bring back up the browser again. :)

Addison 2012-06-24 06:30

Re: Youtube download script
 
I did have one question for you though....

Once I start downloading a video, I'm already browsing for the next one to play while the current one is loading up.

Since the current web page is still "copied", is there perhaps a way to manipulate the copied URL using xclip so it would take you directly to the post a message, view comments, like or dislike the video page if that were something I wanted to do?

auouymous 2012-06-24 08:07

Re: Youtube download script
 
Quote:

Originally Posted by Addison (Post 1226586)
matchbox-remote -next

Does personal launcher open a terminal for the yt script? If so, you should put the matchbox command in personal launcher so it doesn't get overriden whenever I release new versions.

Code:

matchbox-remote -next ; yt ...
The ... is any arguments you might be using with yt.


Quote:

Originally Posted by Addison (Post 1226587)
Since the current web page is still "copied", is there perhaps a way to manipulate the copied URL using xclip so it would take you directly to the post a message, view comments, like or dislike the video page if that were something I wanted to do?

Sure, press the new window button in Tear, tap the URL bar and press ctrl-v to paste in the copied URL. :)

Addison 2012-06-24 08:11

Re: Youtube download script
 
Quote:

Does personal launcher open a terminal for the yt script?
Nope.

Quote:

Sure, press the new window button in Tear, tap the URL bar and press ctrl-v to paste in the copied URL.
*lol*

I knew that.

I was just wondering if you could add to the URL that was copied to save an extra step or two. :)

auouymous 2012-06-24 09:58

Re: Youtube download script
 
Quote:

Originally Posted by Addison (Post 1226616)
Nope.

Then what exactly are you using the matchbox command to switch away from? Anyway, putting the matchbox command in the personal launcher command area will do the same thing as putting it in the yt script.


Quote:

Originally Posted by Addison (Post 1226616)
I was just wondering if you could add to the URL that was copied to save an extra step or two.

Add what to it? The URL that was copied is the URL to the youtube video page that contains the video and comments.

Addison 2012-06-24 10:06

Re: Youtube download script
 
Quote:

Then what exactly are you using the matchbox command to switch away from? Anyway, putting the matchbox command in the personal launcher command area will do the same thing as putting it in the yt script.
Thanks. That just now made sense to me. *lol*

Quote:

Add what to it? The URL that was copied is the URL to the youtube video page that contains the video and comments.
My stupid question was instead of pasting the exact web address back again like this...

http://m.youtube.com/watch?gl=US&hl=...&v=Pwe-pA6TaZk

Instead it would take you here or somewhere else, like posting, viewing or disliking a video...

http://m.youtube.com/rating?gl=US&hl...&v=Pwe-pA6TaZk

Anyway, my question is total garbage now that I think about it. *lol*

You should ignore my many ideas more often. :)

auouymous 2012-06-24 10:36

Re: Youtube download script
 
Quote:

Originally Posted by Addison (Post 1226651)
Instead it would take you here or somewhere else, like posting, viewing or disliking a video...

It would probably be easier to scroll to the bottom of the video page and comment or like it.


Code:

xclip -in `xclip -out |sed 's/watch/rating/'`
That command would take the copied URL and change it to the rating URL and put that back in the clipboard. So you can run a command from personal launcher before pasting the converted URL or just scroll down on the video page after pasting the original URL. :)

Addison 2012-06-25 06:28

Re: Youtube download script
 
I have tried

matchbox-remote -next ; yt
matchbox-remote -next & yt
matchbox-remote -next && yt

None of these will download a video in Personal Launcher.

So for now, I just have it in the beginning part of your script.

Also, I would like to add this as well...

xte 'keydown Escape' 'keyup Escape'

I always go back one page after grabbing a video so this just saves another step.

Where should I put this command?

If I do it right after matchbox-remote -next, the browser will come back up and go back a page, but the video won't download.

So I'm guessing it's going to be needed somewhere in the middle of your script.

I hope my question makes sense to you.

Thanks ahead. :)

Addison 2012-06-25 06:57

Re: Youtube download script
 
Okay, nevermind. I got it to work correctly. :)

Don't ask why, I have no clue, but apparently this is what was needed.

xte 'keydown Up' 'keyup Up' 'keydown Escape' 'keyup Escape'

Addison 2012-06-29 03:22

Re: Youtube download script
 
Hey.

I'm trying to simplify this down to just a single click.

I can't seem to find a way to highlight and copy the url using Tear web browser though.

This is kind of what I have right now.

xte 'mousemove 400 450'
xte 'keydown Control_L' 'key a' 'keyup Control_L'
xte 'keydown Control_L' 'key c' 'keyup Control_L'

Any ideas at all?

auouymous 2012-06-29 03:41

Re: Youtube download script
 
Quote:

Originally Posted by Addison (Post 1228852)
I can't seem to find a way to highlight and copy the url using Tear web browser though.

Code:

xte 'mousemove 400 450' 'mouseclick 1'
xte 'keydown Control_L' 'key c' 'keyup Control_L'

The URL is normally selected when a user clicks in the field but if not then add the ctrl-a back in.

Addison 2012-06-29 03:45

Re: Youtube download script
 
I can't seem to produce a mouseclick.

I've tried 'mouseclick 1' and 'mousedown 1" followed by "mouseup 1"

I tried this using MTPaint and I can get the cursor to move, just not a mouseclick which I think is needed if I'm ever going to grab the URL address.

auouymous 2012-06-29 03:52

Re: Youtube download script
 
Quote:

Originally Posted by Addison (Post 1228855)
I can't seem to produce a mouseclick.

Try other values with mouseclick, such as 0 and 2 and no value (probably will give an error).

Addison 2012-06-29 03:53

Re: Youtube download script
 
I did from 0 to 4 already. :(

auouymous 2012-06-29 04:47

Re: Youtube download script
 
Quote:

Originally Posted by Addison (Post 1228852)
xte 'mousemove 400 450'

I was successfully able to click buttons in ASUI using 'mouseclick 1' and 'mousemove 100 450' 'mouseclick 1' will open a new tab in Tear. I was not able to click into the Tear URL bar or form fields on web pages. It works when selecting memos in Maemopad+ but won't click in the right text pane.

I was able to click in GTK text fields using xte on my Linux desktop but it appears that GTK text fields are not clickable on Maemo, unless something else is required. :(

Addison 2012-06-29 05:03

Re: Youtube download script
 
Ah dern.

Well thank you very much for checking on this. :)

Addison 2012-06-29 05:06

Re: Youtube download script
 
What about moving the mouse and then send something like a right arrow key so that the cursor is then in the URL address bar?

Addison 2012-07-12 06:26

Re: Youtube download script
 
Say I would like to resume something 90 minutes into a video...

Right now, I have to hold the fast forward button for like 15 minutes to get there.

In Linux, is it possible to delete part of a file?

Like cut out the first 200 megs so when I play the file, it will start very close to where I would like to resume watching it?

auouymous 2012-07-12 14:03

Re: Youtube download script
 
Quote:

Originally Posted by Addison (Post 1236405)
Say I would like to resume something 90 minutes into a video...

The "-ss HH:MM:SS" option seeks to a point in the video. Hopefully the tablet version of mplayer supports it. :)

Code:

mplayer my-video.mp4 -ss 0:90

Addison 2012-07-12 14:06

Re: Youtube download script
 
Thanks!

I'll give it a try. :)

Addison 2012-07-13 01:38

Re: Youtube download script
 
Quote:

mplayer my-video.mp4 -ss 0:90
Okay. This only works for .mp4 and .avi files.

I guess .flv can't use this feature. :(

Addison 2012-09-04 02:03

Re: Youtube download script
 
Is there something else running besides mplayer and this script in the background?

When I run yt clean I sometimes get weirdness afterwards.

There will be times when the next video won't begin to play automatically, or it might play super chunky.

Sometimes it will play the video twice at the same time.

Even times when I close the video, it will keep popping back up trying to play itself over and over again.

Just curious, that's all. :)

auouymous 2012-09-04 02:40

Re: Youtube download script
 
Quote:

Originally Posted by Addison (Post 1260614)
Is there something else running besides mplayer and this script in the background?

yt, youtube-dl-x and mplayer should be the only programs running, besides anything you may have running.


Quote:

Originally Posted by Addison (Post 1260614)
When I run yt clean I sometimes get weirdness afterwards.

`yt clean` kills mplayer, kills the previous instance of itself, kills youtube-dl-x and removes the downloaded videos. Nothing weird can happen.


Quote:

Originally Posted by Addison (Post 1260614)
There will be times when the next video won't begin to play automatically, or it might play super chunky.

Next video? I don't recall yt having the ability to queue up videos.


Quote:

Originally Posted by Addison (Post 1260614)
Sometimes it will play the video twice at the same time. Even times when I close the video, it will keep popping back up trying to play itself over and over again.

The original script has nothing that would play the video twice simultaneouly, nor does it have any way to restart mplayer.

What modifications have you made to the script?

Addison 2012-09-04 02:50

Re: Youtube download script
 
This is my download script.

Code:

#!/bin/sh

# version 1.3

# set this to the directory where videos will be downloaded
VIDEO_DOWNLOAD_DIR="/media/mmc1/Videos"
VIDEO_SAVE_DIR="/media/mmc1/Favorites"

# REQUIRED:
# /usr/bin/youtube-dl-x -- http://rg3.github.com/youtube-dl/
# xclip -- http://asui.garage.maemo.org/_download/xclip
# apt-get install libxmu6

# USAGE:
# yt [URL]      -- download and play video in clipboard
# yt get [URL]  -- download video in clipboard
# yt kill      -- kill all downloads and playback
# yt clean      -- remove all downloaded videos
# yt save [URL] -- move already downloaded video in clipboard to saved video directory

#################################
matchbox-remote -next
xte 'keydown Up' 'keyup Up' 'keydown Escape' 'keyup Escape'

if [ "$1" = "get" -o "$1" = "kill" -o "$1" = "clean" -o "$1" = "save" ]; then
        VIDEO=$2
else
        VIDEO=$1
fi
[ "$VIDEO" = "" ] && VIDEO=`xclip -out`
[ "$VIDEO" = "" -a "$1" != "kill" -a "$1" != "clean" ] && echo "Copy a youtube URL to clipboard or specify one on the command line" && exit

if [ "$1" = "kill" ]; then
        killall mplayer
        kill `ps aux|grep "/bin/sh $0"|grep -vE "(grep|kill|clean)"|awk '{print $1}'`
        kill `ps aux|grep "python /usr/bin/youtube-dl-x"|grep -v grep|awk '{print $1}'`
elif [ "$1" = "get" ]; then
        cd "$VIDEO_DOWNLOAD_DIR"
        echo "Downloading $VIDEO..."
        /usr/bin/youtube-dl-x --no-part -f 5 -o "%(stitle)s.%(ext)s" "$VIDEO"
elif [ "$1" = "save" ]; then
        cd "$VIDEO_DOWNLOAD_DIR"
        echo "Saving $VIDEO..."
        FILE=`youtube-dl-x --no-part -c -f 5 -o "%(stitle)s.%(ext)s" --get-filename "$VIDEO"`
        mv "$FILE" "$VIDEO_SAVE_DIR"/
elif [ "$1" = "clean" ]; then
        $0 kill
        rm -f "$VIDEO_DOWNLOAD_DIR"/*
else
        cd "$VIDEO_DOWNLOAD_DIR"
        echo "Downloading $VIDEO..."
        youtube-dl-x --no-part -c -f 5 -o "%(stitle)s.%(ext)s" "$VIDEO" &
        FILE=`youtube-dl-x --no-part -f 5 -o "%(stitle)s.%(ext)s" --get-filename "$VIDEO"`
        while [ ! -f "$FILE" ]; do sleep 5 ; done
        while [ "`/bin/ls -s "$FILE"|awk '{print $1}'`" -lt "4" ]; do sleep 5 ; done
        sleep 30
        mplayer "$FILE"
fi

And this is my clean up script.

Code:

#!/bin/sh

# version 1.3

# set this to the directory where videos will be downloaded
VIDEO_DOWNLOAD_DIR="/media/mmc1/Videos"
VIDEO_SAVE_DIR="/media/mmc1/Favorites"

# REQUIRED:
# /usr/bin/youtube-dl-x -- http://rg3.github.com/youtube-dl/
# xclip -- http://asui.garage.maemo.org/_download/xclip
# apt-get install libxmu6

# USAGE:
# yt [URL]      -- download and play video in clipboard
# yt get [URL]  -- download video in clipboard
# yt kill      -- kill all downloads and playback
# yt clean      -- remove all downloaded videos
# yt save [URL] -- move already downloaded video in clipboard to saved video directory

#################################

if [ "$1" = "get" -o "$1" = "kill" -o "$1" = "clean" -o "$1" = "save" ]; then
        VIDEO=$2
else
        VIDEO=$1
fi
[ "$VIDEO" = "" ] && VIDEO=`xclip -out`
[ "$VIDEO" = "" -a "$1" != "kill" -a "$1" != "clean" ] && echo "Copy a youtube URL to clipboard or specify one on the command line" && exit

if [ "$1" = "kill" ]; then
        killall mplayer
        matchbox-remote -next
        kill `ps aux|grep "/bin/sh $0"|grep -vE "(grep|kill|clean)"|awk '{print $1}'`
        kill `ps aux|grep "python /usr/bin/youtube-dl-x"|grep -v grep|awk '{print $1}'`
elif [ "$1" = "get" ]; then
        cd "$VIDEO_DOWNLOAD_DIR"
        echo "Downloading $VIDEO..."
        /usr/bin/youtube-dl-x --no-part -f 5 -o "%(stitle)s.%(ext)s" "$VIDEO"
elif [ "$1" = "save" ]; then
        cd "$VIDEO_DOWNLOAD_DIR"
        echo "Saving $VIDEO..."
        FILE=`youtube-dl-x --no-part -c -f 5 -o "%(stitle)s.%(ext)s" --get-filename "$VIDEO"`
        mv "$FILE" "$VIDEO_SAVE_DIR"/
elif [ "$1" = "clean" ]; then
        $0 kill
        rm -f "$VIDEO_DOWNLOAD_DIR"/*
else
        cd "$VIDEO_DOWNLOAD_DIR"
        echo "Downloading $VIDEO..."
        youtube-dl-x --no-part -c -f 5 -o "%(stitle)s.%(ext)s" "$VIDEO" &
        FILE=`youtube-dl-x --no-part -f 5 -o "%(stitle)s.%(ext)s" --get-filename "$VIDEO"`
        while [ ! -f "$FILE" ]; do sleep 5 ; done
        while [ "`/bin/ls -s "$FILE"|awk '{print $1}'`" -lt "4" ]; do sleep 5 ; done
        sleep 30
        mplayer "$FILE"
fi

The weirdness I mentioned usually happens on the next video download after I run the yt clean script or when a video didn't download at all for some odd reason.

For me, it's almost as though there's some extra process running in mplayer if that makes any sense.

auouymous 2012-09-04 03:31

Re: Youtube download script
 
Quote:

Originally Posted by Addison (Post 1260625)
This is my download script.

The weirdness I mentioned usually happens on the next video download after I run the yt clean script or when a video didn't download at all for some odd reason.

For me, it's almost as though there's some extra process running in mplayer if that makes any sense.

Looks like the only changes you have are the three matchbox/xte lines. The biggest problem I see is that you have two separate scripts. The kill and clean commands require the scripts to have the same name, which isn't possible with two scripts.

Get rid of the clean up script and move the matchbox line from the kill section to the download script. Wrap the two matchbox/xte lines with the following so they won't be executed when using kill or clean.

Code:

if [ "$1" != "kill" -a "$1" != "clean" ]; then
  matchbox-remote -next
  xte 'keydown Up' 'keyup Up' 'keydown Escape' 'keyup Escape'
fi


Addison 2012-09-04 03:35

Re: Youtube download script
 
Okay. Thank you very much.

I wasn't exactly sure where to place those extra commands so I ended up with two scripts instead.

Cheers buddy. :)

shawnjefferson 2012-09-05 02:10

Re: Youtube download script
 
This script is great, BTW... makes MyTube work for browsing Youtube and then playing the videos via your script. :)

Addison 2012-09-14 06:10

Re: Youtube download script
 
Hey auouymous!

It's very doubtful, but I was wondering if there was any way to support playing video channels from http://www.twitch.tv?

Cheers. :)

auouymous 2012-09-14 06:50

Re: Youtube download script
 
Quote:

Originally Posted by Addison (Post 1266123)
I was wondering if there was any way to support playing video channels from http://www.twitch.tv?

I think youtube-dl supports sites other than youtube, did you try passing it a twitch.tv video url?

Addison 2012-09-14 06:52

Re: Youtube download script
 
No I haven't.

I'll try right now. :)

Addison 2012-09-14 07:05

Re: Youtube download script
 
It looks like you need something called X-Split so that would be a no. :(
http://www.xsplit.com/download/

Oh well, I thought it was a long shot anyway. :)

Addison 2012-09-27 03:27

Re: Youtube download script
 
I'm getting the following error both using m.youtube.com and youtube.com on all videos now.

Code:

Downloading http://m.youtube.com/watch?gl=U S...
[youtube] Setting language
[youtube] watch: Downloading video webpage
ERROR: unable to download video webpage: HTTP Error 404: Not Found
ERROR: unable to download video webpage: HTTP Error 404: Not Found

Any ideas on why this is happening?

Can someone check to see if it still works? :)

auouymous 2012-09-27 04:13

Re: Youtube download script
 
Quote:

Originally Posted by Addison (Post 1272754)
I'm getting the following error both using m.youtube.com and youtube.com on all videos now.
Code:

Downloading http://m.youtube.com/watch?gl=U S...

1) Try removing all the garbage in the URL after the ? except for the v=XXXXXXXXXXX, where X is not an &.

2) See if there is a new version of the youtube-dl script. Youtube changes its format all the time and that requires changes in the download script. The URL to download a new script is in the yt script.

Addison 2012-09-27 04:15

Re: Youtube download script
 
Okay. I'll give it a try.

Thanks. :)

Addison 2012-09-30 05:07

Re: Youtube download script
 
Is the newest version of youtube-dl working for anyone?

http://rg3.github.com/youtube-dl/download.html

auouymous 2012-09-30 09:23

Re: Youtube download script
 
Quote:

Originally Posted by Addison (Post 1274173)
Is the newest version of youtube-dl working for anyone?

Code:

File "/usr/bin/youtube-dl-x", line 2
SyntaxError: Non-ASCII character '\x93' in file /usr/bin/youtube-dl-x on line 3, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details

Looks like we need python 2.6 for the new version to work.


All times are GMT. The time now is 16:24.

vBulletin® Version 3.8.8