Re: Skript för att spela upp svtplay-strömmar i mplayer
Postat: 17 jul 2010, 05:42
Några tips om hur man kan läsa ut rtmp-adressen från tv4play och de andra?
Forum för Ubuntus svenska gemenskap
https://ubuntu-se.servebbs.org/
Kod: Markera allt
#!/usr/bin/perl
# use module
use LWP::Simple;
use XML::Simple;
use Data::Dumper;
# Structure of a programs main page
#html
# body
# div id=wrapper
# div id=sb class="browser showbrowser"
# div class=content
# div class=margin
# div class=show-tab-container animation
# div class=tab-active
# ul class="list small {pagenum:7,rssLink:''}"
# li
# a href
# img src
# span
# *title*
# em
# *date*
my $baseurl = "http://svtplay.se/t/130445/olivia"; # ?cb,a1364151,1,f,-1/pb,a1364150,1,f,-1/pl,v,,2114687/sb,p130446,4,f,-1';
# read pages URL
my $url = XMLin(get($baseurl))->{body}{div}{wrapper}{div}{sb}{div}[0]{ul}{li}{h2}{a}{href};
$url =~ s/\d,f,?-?\d*$//; # remove page selection from internal link
my %shows = ();
my $j = 0;
my $page = 1;
my $pagenum = 1;
do {
my $data = XMLin(get($baseurl . $url. $page))->{body}{div}{wrapper}{div}{sb}{div}[1]{div}{div}{div}; #->{ul};
foreach my $li ( @{$data->[0]->{ul}->{li}})
{
my $name = $li->{a}->{span};
$name =~ s/^\s*//;
$shows{$j++} = {
name => $name,
pub => $li->{a}->{em},
uri => "http://svtplay.se" . $li->{a}->{href},
exists => ((-e "$name.mp4")? 1: 0),
};
#print $j . $li->{a}->{span} . $li->{a}->{em};
#print $j . " http://svtplay.se" . $li->{a}->{href};
#print "\n";
#$j++;
}
if( $data->[0]->{ul}->{class} =~ m/pagenum:(\d),/)
{
$pagenum = $1;
}
#next page
$page++;
} while ($page <= $pagenum);
my $show = shift;
if(!$show || !defined($shows{$show})) {
if ($show ne 'all')
{
usage();
}
else
{
for my $i(sort{$a <=> $b}(keys(%shows))) {
loadshow($i);
}
}
}
else
{
loadshow($show);
}
sub loadshow {
my $selectedshow = $_[0];
my $url = $shows{$selectedshow}->{uri};
my @content = split(/\n/,get("$url")) or die();
my $rtmp = undef;
for(@content) {
if($_ =~ s;.+(rtmp.+mp4-e-v1\.mp4).+;;) {
$rtmp = "'$1'";
last;
}
elsif($_ =~ s;.+(rtmp.+mp4-d-v1\.mp4).+;;) {
$rtmp = "'$1'";
last;
}
elsif($_ =~ s;.+(rtmp.+mp4-c-v1\.mp4).+;;) {
$rtmp = "'$1'";
last;
}
}
print ">>>> $rtmp <<<<\n\n";
if ($shows{$selectedshow}->{exists} == 1)
{
print "\n$shows{$selectedshow}->{name}.mp4 existed: $shows{$selectedshow}->{exists}\n";
}
else
{
print "\n$shows{$selectedshow}->{name}.mp4 did not exist: $shows{$selectedshow}->{exists}\n";
system("rtmpdump -r $rtmp -o \"$shows{$selectedshow}->{name}.mp4\"");
}
}
sub usage {
print << "USAGE";
USAGE: $0 ([show] | all )
\033[1mSHOWS\033[0m:
USAGE
for my $i(sort{$a <=> $b}(keys(%shows))) {
printf("[\033[1m%02d\033[0m] \033[30;1m%s %d\033[0m \033[33m%s\033[0m \n",$i,
$shows{$i}{pub}, $shows{$i}->{exists}, $shows{$i}{name});
}
exit(0);
}
i rtmpdump paketet ingår rtmpsrv följ instruktionerna nedanwebaake skrev:Några tips om hur man kan läsa ut rtmp-adressen från tv4play och de andra?
Kod: Markera allt
$ sudo iptables -t nat -A OUTPUT -p tcp --dport 1935 -j REDIRECT
$ rtmpsrv
RTMP Server v2.3
(c) 2010 Andrej Stepanchuk, Howard Chu; license: GPL
Streaming on rtmp://0.0.0.0:1935
[...]
rtmpdump -r "rtmp://fl11.c91005.cdn.qbrick.com/91005/_definst_" -a "91005/_definst_" -f "LNX 10,2,152,27" -W "http://svtplay.se/flash/svtplayer-2011.3.swf" -p "http://svtplay.se/v/2321925/borgen/del_2_av_10?cb,a1364145,1,f,-1/pb,a1364142,1,f,-1/pl,v,,2321925/sb,p149647,1,f,-1" -y "mp4:kluster/20110209/PG-1134878-002A-BORGEN1EP1-01-mp4-c-v1" -o PG-1134878-002A-BORGEN1EP1-01-mp4-c-v1.flv
[...]
^CCaught signal: 2, cleaning up, just a second...
$ sudo iptables -t nat -D OUTPUT -p tcp --dport 1935 -j REDIRECT
Kod: Markera allt
"mp4:kluster/20110209/PG-1134878-002A-BORGEN1EP1-01-mp4-c-v1"
Kod: Markera allt
"mp4:kluster/20110209/PG-1134878-002A-BORGEN1EP1-01-mp4-e-v1"
Kod: Markera allt
rtmpdump -r "rtmp://fl11.c91005.cdn.qbrick.com:1935/91005/_definst_" -a "91005/_definst_" -f "LNX 10,2,152,27" -W "http://svtplay.se/flash/svtplayer-2011.3.swf" -p "http://svtplay.se/v/2321925/borgen/del_2_av_10?cb,a1364145,1,f,-1/pb,a1364142,1,f,-1/pl,v,,2321925/sb,p149647,1,f,-1" -y "mp4:kluster/20110209/PG-1134878-002A-BORGEN1EP1-01-mp4-e-v1" -o borgen.ep2-e.flv
Kod: Markera allt
rtmpdump -o "blablabla.mp4" -r "rtmpe://blablabla.mp4"
Kod: Markera allt
#!/bin/bash
#
# svtplay.se program rip-script
# v.0.1
#
# by eyerouge with help from foodoo & ubuntu-se wiki.
#
# Worked on all longer svtplay programs as of 13:th of March 2o11.
# Is not intended to work on short clips as svtplay doesnt use rtmp for them, and they're easier to rip anyhow.
# Visit http://ubuntu-se.org/wiki/Howtos/Rippa_fr%C3%A5n_SVT_Play for more loving.
#
# [info] You need only thre thigs: a) rtmpdump installed, b) the svtplay-URL to the specific program/episode and c) the path and name of the destination file.
echo " "
echo "1. The svtplay-URL to the program: "
read url
echo " "
echo "2. Output file: "
read filename
echo " "
echo "---------------------"
echo "Poetry in motion..."
echo "---------------------"
echo " "
rtmpdump -r $(wget -qO- "$url" | egrep -o rtmp[^,]+ | sort -r | uniq | head -n1) --resume -o "$filename.flv"
exit 0
Kod: Markera allt
bash ./filensnamn
Kod: Markera allt
# svtplay.se program rip-script
# v.0.2
#
# by eyerouge with help from foodoo & ubuntu-se wiki.
#
# Worked on all longer svtplay programs as of 13:th of March 2o11.
# Is not intended to work on short clips as svtplay doesnt use rtmp for them, and they're easier to rip anyhow.
# Visit http://ubuntu-se.org/wiki/Howtos/Rippa_fr%C3%A5n_SVT_Play for more loving.
#
# [info] You need only thre thigs: a) rtmpdump installed, b) the svtplay-URL to the specific program/episode and c) the path and name of the destination file.
#
# Syntax:
# $ bash ./scriptname URLtoSVTPlayProgramsSite NameAndPathOfDestinationFile
#
# Output:
# NameAndPathOfDestinationFile.flv
echo " "
rtmpdump -r $(wget -qO- "$1" | egrep -o rtmp[^,]+ | sort -r | uniq | head -n1) --resume -o "$2.flv"
exit 0
Kod: Markera allt
Options:
-d, --download download video to ./
-mp, --mplayer play video using mplayer
-l, --list pick a video from the most recent ones
-b, --bitrate choose bitrate?
-s, --subtitle choose subtitle?
-h, --help show the help and exit
-v, --version show version info and exit
-m, --man show the manual and exit
Det har fungerat för mig vid kanske 1-2 tillfällen. Generellt sett instämmer jag dock: Det är absolut inget att förlita sig på, men ser å andra sidan inte att det skulle skada att ge det ett försök heller.m!rage skrev:Gött! Jag tror förresten att du kan ta bort --resume, det har nämligen aldrig fungerat för mig att återuppta en avbruten nerladdning
Kod: Markera allt
eyerouge@eyerouge:~$ wget -qO- "http://svtplay.se/t/151811/premiar_for_smartare_an_en_femteklassare" | egrep -o rtmp[^,]+ | sort -r | uniq
Kod: Markera allt
wget -qO- "http://svtplay.se/t/151811/premiar_for_smartare_an_en_femteklassare" | egrep -o rtmp[^,]+ | sort -r | uniq | head -n1
Kod: Markera allt
wget -qO- "http://svtplay.se/t/151811/premiar_for_smartare_an_en_femteklassare" | egrep -o rtmp[^,]+ | sort -r | uniq | head -n2 | tail -1
Kod: Markera allt
rtmpe://fl11.c90909.cdn.qbrick.com/90909/_definst_/kluster/20110319/PG-1155944-001A-VARNOJE2011S-01-mp4-e-v1.mp4
rtmpe://fl11.c90909.cdn.qbrick.com/90909/_definst_/kluster/20110319/PG-1155944-001A-VARNOJE2011S-01-mp4-d-v1.mp4
rtmpe://fl11.c90909.cdn.qbrick.com/90909/_definst_/kluster/20110319/PG-1155944-001A-VARNOJE2011S-01-mp4-c-v1.mp4
rtmpe://fl11.c90909.cdn.qbrick.com/90909/_definst_/kluster/20110319/PG-1155944-001A-VARNOJE2011S-01-mp4-b-v1
Kod: Markera allt
echo "Skriv in URL:"
read URL1
wget -qO- "$URL1" | egrep -o rtmp[^,]+ | sort -r | uniq
echo "Kopiera och klistra in rtmpe adressen: "
read URL2
echo "Skriv in filnamnet:"
read FILNAMN
rtmpdump -r "$URL2" --resume -o "$FILNAMN.mp4"
exit 0
Går garanterat att dumpa varje grej i listan som en variabel (lite på ditt array-spår), sedan helt enkelt bara ange en siffra som i sin tur anger vilken variabel som ska användas istället för att klippa och klistra fram URL2... syftet är att slippa klistrandet helt.webaake skrev: Tack vare din fina kod räcker det med webadressen (URL1) för att söka ut och sedan lista alternativen. Funkar fint för mig.
Kod: Markera allt
N=0
for i in $(wget -qO- "$URL1" | egrep -o rtmp[^,]+ | sort -r | uniq) ; do
testarray[$N]="$i"
echo "$N = $i" #to confirm the entry
let "N= $N + 1"
Kod: Markera allt
echo "Skriv in URL:"
read URL1
N=0
for i in $(wget -qO- "$URL1" | egrep -o rtmp[^,]+ | sort -r | uniq) ; do
testarray[$N]="$i"
echo "$N = $i" #to confirm the entry
let "N= $N + 1"
done
echo "Välj 0,1,2 .... ;"
read VAL
URL2=${testarray["$VAL"]}
echo "Du har valt:"
echo "$URL2"
echo "--------"
echo "Skriv in filnamnet:"
read FILNAMN
rtmpdump -r "$URL2" --resume -o "/home/mrmedia/VIDEO/$FILNAMN.mp4"
exit 0