You are not logged in.

#1 2010-05-01 02:01:23

cesura
Package Maintainer (PM)
From: Tallinn, Estonia
Registered: 2010-01-23
Posts: 1,867

Little script to automatically play flash videos in MPlayer

I just wrote up a little script to play flash videos automatically. I have only tested this with youtube videos.

Things needed to be implemented:
- Pausing or muting the current flash video so you can watch the video in MPlayer without having to pause the Flash video manually
- Have MPlayer close when the user goes to a different page
- Support for multiple videos

Do what you want with it. I simply run the script in xterm in a different tab on Awesome and have it in the background.

#!/bin/sh

while [ 1 ]; do # Endless Loop
    if [ -f /tmp/Flash* ] # Check if flash video exists
    then
        echo "Waiting to start video..." #Count Down
        for (( c=3; c>0; c-- ))
        do
            echo "Starting video in $c seconds"
            sleep 1
        done    
        mplayer /tmp/Flash* # Play video
    else
        sleep 2 # Put in to lower CPU consumption
    fi
done

Really, not impressive, but it will have to do for now

To change the countdown time, change the value of $c in the for loop (seconds)

NOTE: If /bin/sh is not symlinked to your shell, please change the script, replacing sh with your shell.

Last edited by cesura (2010-07-03 03:10:35)

Offline

#2 2010-05-01 04:08:55

Tyriel
Member
From: Melbourne, Australia
Registered: 2009-01-20
Posts: 161
Website

Re: Little script to automatically play flash videos in MPlayer

I like the general idea of this and it does have potential as a replacement to flash players.  Most of which I do not like.


The software required Windows XP or better, so I installed archlinux.

Offline

#3 2010-05-01 04:26:45

cesura
Package Maintainer (PM)
From: Tallinn, Estonia
Registered: 2010-01-23
Posts: 1,867

Re: Little script to automatically play flash videos in MPlayer

Tyriel wrote:

I like the general idea of this and it does have potential as a replacement to flash players.  Most of which I do not like.

As of now, it requires flash simply to stream the video to the /tmp directory, MPlayer just makes it extremely faster. A couple of more mods and it could become something useful for everybody smile

Offline

#4 2010-05-01 11:05:00

JohannesSM64
Member
From: Norway
Registered: 2009-10-11
Posts: 623
Website

Re: Little script to automatically play flash videos in MPlayer

The shebang should be #!/bin/bash. sh doesn't support C-like for loops, it's just silly bash that happily uses bash-specific functionality even when invoked in compatibility mode (sh)

Offline

#5 2010-05-01 11:25:10

dmz
Member
From: Sweden
Registered: 2008-08-27
Posts: 881
Website

Re: Little script to automatically play flash videos in MPlayer

Give this a youtube url, and it will play it straight
in mplayer - no need for flash, no need to buffer the
whole vid, no need to play it from /tmp;
All props to zibri.

#!/usr/bin/perl
use LWP::Simple;

my $player = 'mplayer';
my $url = shift or die("Needs argument");
my $body = get($url);
my($t) = $body =~ /"t":\s*"(.+?)"/is;
my($video_id) = $body =~ /"video_id":\s*"(.+?)"/is;
my $real_url = "http://www.youtube.com/get_video?video_id=$video_id&t=$t";
print "$real_url\n";
system("$player '$real_url'"); 
exit 0;

Offline

#6 2010-05-01 16:20:06

cesura
Package Maintainer (PM)
From: Tallinn, Estonia
Registered: 2010-01-23
Posts: 1,867

Re: Little script to automatically play flash videos in MPlayer

dmz wrote:

Give this a youtube url, and it will play it straight
in mplayer - no need for flash, no need to buffer the
whole vid, no need to play it from /tmp;
All props to zibri.

#!/usr/bin/perl
use LWP::Simple;

my $player = 'mplayer';
my $url = shift or die("Needs argument");
my $body = get($url);
my($t) = $body =~ /"t":\s*"(.+?)"/is;
my($video_id) = $body =~ /"video_id":\s*"(.+?)"/is;
my $real_url = "http://www.youtube.com/get_video?video_id=$video_id&t=$t";
print "$real_url\n";
system("$player '$real_url'"); 
exit 0;

Cool, except it doesn't run when you click on a video, or does it?

Offline

#7 2010-05-01 16:47:19

crocowhile
Member
Registered: 2009-10-18
Posts: 56

Re: Little script to automatically play flash videos in MPlayer

itsbrad212 wrote:

Cool, except it doesn't run when you click on a video, or does it?

It doesn't but it should be easy to make a greasmonkey/chrome userscript to do that.

Offline

#8 2010-05-01 17:03:55

cesura
Package Maintainer (PM)
From: Tallinn, Estonia
Registered: 2010-01-23
Posts: 1,867

Re: Little script to automatically play flash videos in MPlayer

crocowhile wrote:
itsbrad212 wrote:

Cool, except it doesn't run when you click on a video, or does it?

It doesn't but it should be easy to make a greasmonkey/chrome userscript to do that.

Greasemonkey would probably be better as I don't think there is a plug-in for Firefox for chrome userscripts, and I do believe that greasemonkey scripts can be run on firefox AND chromium.

EDIT:

The shebang should be #!/bin/bash. sh doesn't support C-like for loops, it's just silly bash that happily uses bash-specific functionality even when invoked in compatibility mode (sh)

It all works fine in zsh...

Last edited by cesura (2010-05-01 17:10:40)

Offline

#9 2010-05-02 02:59:06

elliott
Member
Registered: 2006-03-07
Posts: 296

Re: Little script to automatically play flash videos in MPlayer

I use this on Chromium:
http://userscripts.org/scripts/show/50771

Makes Youtube tolerable on my 7" EeePC with a Celeron.

Offline

#10 2010-05-02 04:29:11

cesura
Package Maintainer (PM)
From: Tallinn, Estonia
Registered: 2010-01-23
Posts: 1,867

Re: Little script to automatically play flash videos in MPlayer

elliott wrote:

I use this on Chromium:
http://userscripts.org/scripts/show/50771

Makes Youtube tolerable on my 7" EeePC with a Celeron.

I tried that script with greasemonky before, but there were problems, which is what caused me to write this

Last edited by cesura (2010-05-02 04:29:30)

Offline

#11 2010-07-02 00:52:49

ganastasiou
Member
Registered: 2010-02-03
Posts: 56

Re: Little script to automatically play flash videos in MPlayer

thnx for that,indeed it is necessery for flashplugin-crap!

Offline

#12 2010-07-02 03:27:24

YamiFrankc
Member
From: Mexico
Registered: 2009-06-19
Posts: 177
Website

Re: Little script to automatically play flash videos in MPlayer

Im trying to use dmz's script and i get this.

┌─[yamifrankc]──(~)
└─╼ perl youtube.pl http://www.youtube.com/watch?v=5JOpQD2VNaE&playnext_from=TL&videos=pIcVAkdz0qs&feature=grec_index
zsh: parse error near `&

Why?


Thanks and greetings.

Offline

#13 2010-07-02 05:41:44

dmz
Member
From: Sweden
Registered: 2008-08-27
Posts: 881
Website

Re: Little script to automatically play flash videos in MPlayer

Because you're not escaping bad chars in the url.
perl youtube.pl 'http...'

Offline

#14 2010-07-02 21:09:13

YamiFrankc
Member
From: Mexico
Registered: 2009-06-19
Posts: 177
Website

Re: Little script to automatically play flash videos in MPlayer

Ah, thanks.
Works like a charmm because i do not see many video like having an script running endless tongue.


Thanks and greetings.

Offline

#15 2010-07-02 21:31:34

jakobm
Member
Registered: 2008-03-24
Posts: 132

Re: Little script to automatically play flash videos in MPlayer

Follows the same idea of dmz's perl script:

mplayer $(youtube-dl -g $URL)

Offline

#16 2010-07-02 22:00:08

cesura
Package Maintainer (PM)
From: Tallinn, Estonia
Registered: 2010-01-23
Posts: 1,867

Re: Little script to automatically play flash videos in MPlayer

jakobm wrote:

Follows the same idea of dmz's perl script:

mplayer $(youtube-dl -g $URL)

That is much smaller smile

Problem with that is it doesn't start automatically when you visit a youtube page, and it requires yet another program.

Offline

#17 2010-07-02 22:06:24

JohannesSM64
Member
From: Norway
Registered: 2009-10-11
Posts: 623
Website

Re: Little script to automatically play flash videos in MPlayer

itsbrad212 wrote:

[
EDIT:

The shebang should be #!/bin/bash. sh doesn't support C-like for loops, it's just silly bash that happily uses bash-specific functionality even when invoked in compatibility mode (sh)

It all works fine in zsh...

Yes, I didn't claim otherwise. It doesn't in sh, however. Please read my post again.

Offline

#18 2010-07-02 23:29:52

stqn
Member
Registered: 2010-03-19
Posts: 1,191
Website

Re: Little script to automatically play flash videos in MPlayer

Not to hijack this thread, but it looks like

mplayer -cache 8192 -cache-min 10 $(youtube-dl -bg $url)

works fairly well... (as long as the cache doesn't run out.) Thanks jakobm!

As for the automatic starting... I'll see if I can start this from a keypress in Firefox (I think it's quite doable.)

Offline

#19 2010-07-03 03:08:51

cesura
Package Maintainer (PM)
From: Tallinn, Estonia
Registered: 2010-01-23
Posts: 1,867

Re: Little script to automatically play flash videos in MPlayer

JohannesSM64 wrote:
itsbrad212 wrote:

[
EDIT:

The shebang should be #!/bin/bash. sh doesn't support C-like for loops, it's just silly bash that happily uses bash-specific functionality even when invoked in compatibility mode (sh)

It all works fine in zsh...

Yes, I didn't claim otherwise. It doesn't in sh, however. Please read my post again.

I was simply saying that it has worked (for me) in bash and zsh. It could work in many more. And I thought many people had /bin/sh a symlink to their shell. I'll adjust the first post accordingly.

Last edited by cesura (2010-07-03 03:09:17)

Offline

#20 2010-07-03 07:35:17

Army
Member
Registered: 2007-12-07
Posts: 1,784

Re: Little script to automatically play flash videos in MPlayer

For a really nice youtube experience I recommend minitube for the gui people and youtube-viewer (AUR) for the cli people :-)

Offline

#21 2010-07-03 08:16:13

dmz
Member
From: Sweden
Registered: 2008-08-27
Posts: 881
Website

Re: Little script to automatically play flash videos in MPlayer

Army wrote:

For a really nice youtube experience I recommend minitube for the gui people and youtube-viewer (AUR) for the cli people :-)

youtube-viewer was very nice. The code, however, was not... I'll fix that.

Offline

#22 2010-07-03 13:18:05

Army
Member
Registered: 2007-12-07
Posts: 1,784

Re: Little script to automatically play flash videos in MPlayer

dmz wrote:

youtube-viewer was very nice. The code, however, was not... I'll fix that.

Nice :-)

Offline

#23 2010-07-22 22:13:58

Rasi
Member
From: Germany
Registered: 2007-08-14
Posts: 1,914
Website

Re: Little script to automatically play flash videos in MPlayer

youtube-viewer will simply close if you let it play a video with 3-digit numbers....


He hoped and prayed that there wasn't an afterlife. Then he realized there was a contradiction involved here and merely hoped that there wasn't an afterlife.

Douglas Adams

Offline

#24 2010-08-27 09:06:04

archman-cro
Member
From: Croatia
Registered: 2010-04-04
Posts: 943
Website

Re: Little script to automatically play flash videos in MPlayer

NVM - mod, erase.

Last edited by archman-cro (2010-08-27 09:09:58)

Offline

#25 2011-11-07 16:13:23

diegoviola
Member
Registered: 2010-12-16
Posts: 132

Re: Little script to automatically play flash videos in MPlayer

Deleted.

Last edited by diegoviola (2023-04-17 22:28:39)

Offline

Board footer

Powered by FluxBB