Skip to content

Commit

Permalink
OK madebytravisci
Browse files Browse the repository at this point in the history
  • Loading branch information
danog committed Sep 21, 2015
1 parent 0a27501 commit e98be42
Show file tree
Hide file tree
Showing 27 changed files with 676 additions and 63 deletions.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
video-dl (3.3-31-g0a27501) precise; urgency=low

* travis ci support

-- Daniil <[email protected]> Mon, 21 Sep 2015 22:21:18 +0000

video-dl (1.3.3) stable; urgency=medium

* Fixed auto update and squashed some bugs.
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,23 @@
#!/bin/bash
# Video download script v3.3
# Created by Daniil Gentili (http://daniil.it)
# This program is licensed under the GPLv3 license.
# Video-dl - Video download programs
#
# Copyright (C) 2015 Daniil Gentili
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# Changelog:
# v1 (and revisions): initial version.
# v2 (and revisions): added support for Rai Replay, support for multiple qualities, advanced video info and custom API server.
Expand All @@ -10,10 +26,12 @@
# v3.2 Added support for youtube and https
# v3.3 Fixed auto update and squashed some bugs.

echo "This program is licensed under the GPLv3 license."
echo "Video download script - Copyright (C) 2015 Daniil Gentili
This program comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are welcome to redistribute it
under certain conditions; see the LICENSE file."
help() {
echo "Video download script
Created by Daniil Gentili
echo "Created by Daniil Gentili
Supported websites: $(wget -q -O - http://api.daniil.it/?p=websites)
Usage:
$(basename $0) [ -qabp=player ] URL URL2 URL3 ...
Expand Down Expand Up @@ -96,14 +114,16 @@ case "$FLAG" in
{
echo -n "Downloading latest version of the API engine..." && eval "$(dl http://daniil.magix.net/api.sh - $Q)" && lineclear && type api | grep -q replaytv || {
echo "Couldn't download the API engine, using built-in (maybe outdated) engine..."

# 1st part ends here
api() {
####################################################
####### Beginning of URL recognition section #######
####################################################

dl="$(echo $1 | grep -q '^//' && echo http:$1 || echo $1)"

dl="$(echo "$dl" | sed 's/#.*//;s/https:\/\//http:\/\//g')"
#dl="$(echo "$dl" | sed 's/#.*//;s/https:\/\//http:\/\//g')"

urltype="$(curl -w "%{url_effective}\n" -L -s -I -S "$dl" -o /dev/null)"

Expand Down Expand Up @@ -198,6 +218,8 @@ esac

formats="$(
[ "$common" != "" ] && for a in $common; do getsize
info="$(echo "$info" | sed 's/[(]//;s/[)]//')"
echo "$info $a";done
[ "$lamp4" != "" ] && for a in $lamp4; do getsize
Expand Down Expand Up @@ -268,7 +290,7 @@ formats="$(
)"

formats="$(echo "$formats" | awk '!x[$0]++' | awk '{print $(NF-1), $0}' | sort -g | cut -d' ' -f2-)"
formats="$(echo "$formats" | awk '!x[$0]++' | awk '{print $(NF-1), $0}' | sort -gr | cut -d' ' -f2-)"
[ "$formats" = "" ] && exit


Expand Down Expand Up @@ -329,20 +351,14 @@ esac
tmpjson="$(wget http://www.rai.it/dl/portale/html/palinsesti/replaytv/static/"$ch"_$day.html -qO-)"

# Keep only section with correct video id and make it grepable
json="$(
echo "$tmpjson" | sed '/'$v'/,//d;s/\,/\
/g;s/\"/\
/g;s/\\//g' | tac | awk "flag != 1; /\}/ { flag = 1 }; " | tac
)"
json="$(echo $tmpjson | sed 's/'$v'.*//g;s/.*[{]//g;s/\,/\
/g')"

# Get the relinkers
replay=$(echo "$json" | grep mediapolis | sort | awk '!x[$0]++')
replay=$(echo "$json" | grep mediapolis | sed 's/.*\"://g;s/\"//g;s/^ *//g')

# Get the title
videoTitolo=$(echo "$json" | grep -A 2 '^t$' | awk 'END{print}')
videoTitolo=$(echo "$json" | grep '"t":' | sed 's/.*\"://;s/\"//g;s/^ *//g')


}
Expand All @@ -358,7 +374,7 @@ function relinker_rai() {

for f in $(echo $* | awk '{ while(++i<=NF) printf (!a[$i]++) ? $i FS : ""; i=split("",a); print "" }'); do

dl=$(echo $f | grep -q http: && echo $f || echo http:$f)
dl=$(echo $f | grep -q '^//' && echo http:$f || echo $f)

# 1st method

Expand Down Expand Up @@ -399,8 +415,8 @@ base="$(echo "$TMPURLS" | sort | awk '!x[$0]++')"

# Find all qualities in every video
tbase=
for t in _400.mp4 _600.mp4 _800.mp4 _1200.mp4 _1500.mp4 _1800.mp4 .mp4; do for i in _400.mp4 _600.mp4 _800.mp4 _1200.mp4 _1500.mp4 _1800.mp4; do tbase="$tbase
$(echo "$base" | sed "s/$t/$i/")"; tbase="$(echo "$tbase" | awk '!x[$0]++')"; done;done
for t in _400\\.mp4 _600\\.mp4 _800\\.mp4 _1200\\.mp4 _1500\\.mp4 _1800\\.mp4 \\.mp4; do for i in _400\\.mp4 _600\\.mp4 _800\\.mp4 _1200\\.mp4 _1500\\.mp4 _1800\\.mp4; do tbase="$tbase
$(echo "$base" | sed "s/$t/$i/")"; tbase="$(echo "$tbase" | grep -Ev '_([0-9]{3,4})_([0-9]{3,4})\.mp4' | awk '!x[$0]++')"; done;done


base="$tbase"
Expand All @@ -419,13 +435,14 @@ formatoutput


function rai() {

saferai="$(echo "$1" | sed 's/#.*//g')"
# Store the page in a variable
file=$(wget $1 -q -O -)
file=$(wget "$saferai" -q -O -)

# Rai replay or normal rai website choice
echo $1 | grep -q http://www.*.rai..*/dl/replaytv/replaytv.html.* && replay $1 || rai_normal $1
echo "$1" | grep -q http://www.*.rai..*/dl/replaytv/replaytv.html.* && replay "$saferai" || rai_normal "$saferai"

videoTitolo="$(echo -en "$videoTitolo")"
title="${videoTitolo//[^a-zA-Z0-9 ]/}"
title=`echo $title | tr -s " "`
title=${title// /_}
Expand Down Expand Up @@ -504,8 +521,6 @@ formatoutput

###########################################################################################
##################### End of Mediaset section, beginning of common section ################
###########################################################################################

common() {
# Store the page in a variable
page="$(wget -q -O - $1)"
Expand Down Expand Up @@ -564,6 +579,7 @@ $ptype $dl $2 $3
[ "$formats" = "" ] && continue || echo "$title $videoTitolo
$formats"
}
# 2nd part starts here
}
}
;;
Expand Down Expand Up @@ -657,9 +673,3 @@ done


[ "$queue" = "" ] && { echo "ERROR: download list is empty."; exit 1; }

[ "$play" != "y" ] && { echo "Downloading videos..." && eval "$queue" && echo "All downloads completed successfully." || echo "An error occurred";exit 1; }
[ "$play" = "y" ] && { eval $queue || echo "An error occurred";exit 1; }


exit $?
Loading

0 comments on commit e98be42

Please sign in to comment.