Labo

Sign in or create your account | Project List | Help

Labo Commit Details

Date:2008-11-26 16:56:13 (1 year 9 months ago)
Author:naps
Commit:e365668da0f9ff6cd77b136a7c2542199b1d93ff
Message:Import of ggg (old svn-revisions lost)

Files: ggg/batchy/ggg (1 diff)
ggg/batchy/scripts/getdescript.sh (1 diff)
ggg/batchy/scripts/getguignols.sh (1 diff)
ggg/batchy/scripts/listguigols.sh (1 diff)
ggg/batchy/scripts/selectguignols.sh (1 diff)
ggg/ggg (1 diff)

Change Details

ggg/batchy/ggg
1#!/bin/bash
2#
3# Copyright 2006 Antoine 'NaPs' Millet <antoine@inaps.org>
4# Copyright 2006 Nicolas 'Batchy'
5#
6# This program is free software; you can redistribute it and/or modify
7# it under the terms of the GNU General Public License as published by
8# the Free Software Foundation; either version 3 of the License, or
9# (at your option) any later version.
10#
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14# GNU General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License
17# along with this program; if not, write to the Free Software
18# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19# MA 02110-1301, USA.
20#
21
22# Configuration :
23
24OUTPUT_DIR=~/video/Guignols
25TMP_DIR=/tmp
26
27# Fin de la configuration
28
29SCRIPT_VERSION=0.2.2
30
31
32usage () {
33    echo "Usage: ggg [-hvql] [AAMMJJ | today | yesterday] [Fichier de" \
34    "sortie]"
35    echo "Telecharger, et reencoder dans un format compatible avec les" \
36    "tablettes Nokia,"
37    echo "un episode des guignols suivant son jour de diffusion."
38    echo ""
39    echo " -h, --help affiche cette page d'aide"
40    echo " -v, --version affiche la version et quitte"
41    echo " -q, --high-quality encode avec une haute qualite"
42    echo " Recommande pour le Nokia N800"
43    echo " -l, --low-quality encode avec une basse qualite"
44    echo " Recommande pour le Nokia 770"
45    echo " --download-only"
46    echo " N'encode pas le fichier apres telechargement."
47    echo " --encode-only"
48    echo " Encode le fichier deja telecharge avec" \
49    "--download-only"
50    echo ""
51    echo "Par defaut, le script utilise l'option --high-quality."
52    echo "Si -q et -l sont utilisees en meme temps, la derniere"
53    echo "selectionnee sera prise en compte."
54}
55
56version () {
57    echo "ggg (Get GuiGnols) $SCRIPT_VERSION"
58    echo "Ecrit par Antoine 'NaPs' Millet avec quelques contributions"
59    echo "This is free software; see the source for copying conditions." \
60    "There is NO"
61    echo "warranty; not even for MERCHANTABILITY or FITNESS FOR A" \
62    "PARTICULAR PURPOSE."
63}
64
65quality='low'
66encode='yes'
67download='yes'
68
69while getopts ":vh-:" opt ; do
70    case $opt in
71        h ) usage ; exit ;;
72        v ) version ; exit ;;
73
74        q ) quality="high" ;;
75        l ) quality="low" ;;
76        - ) case $OPTARG in
77            help ) usage ; exit ;;
78            version ) version ; exit ;;
79
80            high-quality ) quality="high" ;;
81            low-quality ) quality="low" ;;
82            download-only ) encode="no" ;;
83            encode-only ) download="no" ;;
84            * )
85            echo "Option illegale --$OPTARG"
86            exit 1
87            ;;
88        esac ;;
89        ? )
90        echo "Option illegale -$OPTARG"
91        exit 1
92        ;;
93    esac
94done
95shift $(($OPTIND -1))
96
97# Ceci constitue les choix par defaut
98date=${1:-yesterday}
99
100if [ $encode = "no" -a $download = "no" ] ; then
101    echo "Options contradictoires : --download-only --encode-only"
102    exit 1
103fi
104
105case $date in
106    today ) gdate=$(date +%y%m%d) ;;
107    yesterday ) gdate=$(date --date 'yesterday' +%y%m%d) ;;
108    * ) gdate=$date;;
109esac
110
111if [ ! -d $OUTPUT_DIR ] ; then
112    mkdir -p $OUTPUT_DIR
113fi
114output=${2:-"$OUTPUT_DIR/Guignol-$gdate.avi"}
115
116dumpfile=$TMP_DIR/guignols_$gdate.dump
117
118if [ ! -d $TMP_DIR ] ; then
119    echo "Impossible de localiser le repertoire temporaire"
120    echo "Editez ggg et remplacez la variable TMP_DIR"
121    exit 2
122fi
123
124if [ $download = "yes" ] ; then
125
126    # determine the URL
127
128    listoutput=`mktemp`
129
130    # get the video number from the list
131
132    # the link http://www.canalplus.fr/c-humour/pid1784-c-les-guignols.html
133    # redirects there
134
135    wget -q "http://www.canalplus.fr/index.php?pid=1784" -O $listoutput
136    if [ ! -s $listoutput ]; then
137        echo "Impossible de telecharger la liste de video"
138        exit 1;
139    fi
140
141    descriptiondate="`echo $gdate |
142    sed -r "s@([0-9]{2})([0-9]{2})([0-9]{2})@\3/\2/\1@" `"
143    if [ ! "$descriptiondate" ]; then
144        echo "Format de date invalide."
145        rm -f $listoutput
146        exit 1;
147    fi
148
149    video_id=`sed -r -n -e "\\%\\['CONTENT_ID'\\] = %N" \
150    -e "s%^.+\"([0-9]+)\".+\\n.+title=\"[^\"]*$descriptiondate[^\"]*\".*\$%\1%p" \
151    < $listoutput `
152
153    if [ ! "$video_id" ]; then
154        echo "Impossible de trouver l'emission du $descriptiondate"
155        rm -f $listoutput
156        exit 1
157    fi
158
159    # now let's get the data and retrieve the url.
160    wget -q --post-data="video_id=$video_id" -O $listoutput \
161    "http://www.canalplus.fr/flash/xml/module/embed-video-player/embed-video-player.php"
162
163    if [ ! -s "$listoutput" ]; then
164        echo "Impossible de telecharger des informations sur la video."
165        rm -f $listoutput
166        exit 1
167    fi
168
169    url="`sed -n -r -e "/<hi>/s/^.*(http:.+)\\]\\].+$/\1/p" < $listoutput`"
170
171    rm -r $listoutput
172    if [ ! "$url" ]; then
173        echo "Impossible de recuperer l'URL de la video"
174        exit 1
175    fi
176
177    echo "Telechargement du stream..."
178    echo "(Cela prend une dizaine de minutes)"
179    rm -f $dumpfile
180    wget $url -O $dumpfile
181    if [ ! -s $dumpfile ] ; then
182        echo "Impossible de capturer le stream !"
183        rm -f $dumpfile
184        exit 1
185    fi
186fi
187
188
189
190if [ $encode = "yes" ] ; then
191
192    if [ ! -r $dumpfile ] ; then
193        echo "Le fichier $dumpfile n'a pas ete telecharge."
194        echo "Impossible d'encoder"
195        exit 1
196    fi
197
198    echo "Re-encodage du fichier..."
199    echo "(Cela peut prendre du temps selon la vitesse du processeur)"
200    case $quality in
201        low )
202        mencoder $dumpfile -o $output -oac mp3lame -idx -ffourcc DIVX \
203        -ofps 25.0 -lameopts abr:br=64:vol=1 -af volnorm -ovc lavc \
204        -lavcopts vcodec=mpeg4:dark_mask=0.15:aspect=15/9:vbitrate=256:trell=yes:v4mv=yes:vpass=1 -vf crop=506:304,scale=288:208,eq2=1.4:1.2:0.0:1.4 \
205        2>&1 > /dev/null
206
207        mencoder $dumpfile -o $output -oac mp3lame -idx -ffourcc DIVX \
208        -ofps 25.0 -lameopts abr:br=64:vol=1 -af volnorm -ovc lavc \
209        -lavcopts vcodec=mpeg4:dark_mask=0.15:aspect=15/9:vbitrate=256:trell=yes:v4mv=yes:vpass=2 -vf crop=506:304,scale=288:208,eq2=1.4:1.2:0.0:1.4 \
210        2>&1 > /dev/null
211        ;;
212        high )
213        mencoder $dumpfile -o $output -oac mp3lame -idx -ffourcc DIVX \
214        -ofps 25.0 -lameopts abr:br=64:vol=1 -af volnorm -ovc lavc \
215        -lavcopts vcodec=mpeg4:dark_mask=0.15:aspect=15/9:vbitrate=512:trell=yes:v4mv=yes:vpass=1 -vf crop=506:304,scale=352:288,eq2=1.4:1.2:0.0:1.4 \
216        2>&1 > /dev/null
217        mencoder $dumpfile -o $output -oac mp3lame -idx -ffourcc DIVX \
218        -ofps 25.0 -lameopts abr:br=64:vol=1 -af volnorm -ovc lavc \
219        -lavcopts vcodec=mpeg4:dark_mask=0.15:aspect=15/9:vbitrate=512:trell=yes:v4mv=yes:vpass=2 -vf crop=506:304,scale=352:288,eq2=1.4:1.2:0.0:1.4 \
220        2>&1 > /dev/null
221        ;;
222    esac
223    if [ -e $output ] ; then
224        echo "L'episode a ete correctement telecharge et encode dans le"
225        echo "fichier $output :-)"
226    else
227        echo "Damned, l'encodage n'a pas reussi :-("
228        exit 1
229    fi
230else
231    echo "Stream telecharge dans le fichier $dumpfile."
232fi
ggg/batchy/scripts/getdescript.sh
1#!/bin/sh
2
3# TODO :
4# - pouvoir choisir entre la haute qualitée et la basse qualitée.
5# - vérifier si le numero correspond à un guignols de l'info
6
7
8
9if [ ! "$1" ]; then
10    echo "
11GetGuiGnols.
12Ce script télécharge une vidéo des guignols de l'info connaissant son numéro.
13Vous pouvez obtenir les numéros disponibles avec ListGuiGnols
14
15usage : ./getguignols <lenumero>
16"
17    exit 1;
18fi
19
20wget --post-data="video_id=$1" "http://www.canalplus.fr/flash/xml/module/embed-video-player/embed-video-player.php" -O embed-video-player.php-$1
21
22#cat embed-video-player.php
23
24if [ "$?" -ne "0" ]; then
25    echo "Erreur lors du téléchargement des informations du contenu."
26    exit 1
27fi
28
29URL=`sed -n -r -e "/<hi>/s/^.*(http:.+)\\]\\].+$/\1/p" < embed-video-player.php`
30if [ "$URL" ]; then echo $URL; fi
ggg/batchy/scripts/getguignols.sh
1#!/bin/sh
2
3# TODO :
4# - pouvoir choisir entre la haute qualitée et la basse qualitée.
5# - vérifier si le numero correspond à un guignols de l'info
6
7
8
9if [ ! "$1" ]; then
10    echo "
11GetGuiGnols.
12Ce script télécharge une vidéo des guignols de l'info connaissant son numéro.
13Vous pouvez obtenir les numéros disponibles avec ListGuiGnols
14
15usage : ./getguignols <lenumero>
16"
17    exit 1;
18fi
19
20wget -N --post-data="video_id=$1" "http://www.canalplus.fr/flash/xml/module/embed-video-player/embed-video-player.php"
21
22cat embed-video-player.php
23
24if [ "$?" -ne "0" ]; then
25    echo "Erreur lors du téléchargement des informations du contenu."
26    exit 1
27fi
28
29URL=`sed -n -r -e "/<hi>/s/^.*(http:.+)\\]\\].+$/\1/p" < embed-video-player.php`
30
31if [ ! "$URL" ]; then
32    echo "Impossible de télécharger. Peut être vous êsts vous trompés de numéro ?"
33fi
34
35echo "Téléchargement en cours, veuillez patientez ..."
36wget -N "$URL"
37
38if [ "$?" -ne "0" ]; then
39    echo "Erreur lors du téléchargement de la vidéo."
40    echo "Le lien du téléchargement était le suivant :"
41    echo "$URL"
42    exit 1
43fi
44
ggg/batchy/scripts/listguigols.sh
1#!/bin/sh
2
3wget -N http://www.canalplus.fr/c-humour/pid1784-c-les-guignols.html
4
5sed -r -n -e "/\\['CONTENT_ID'\\] = /N" \
6    -e "s/^.+\"([0-9]+)\".+\\n.+title=\"([^\"]+)\".*$/\1:\2/p" \
7    < index.php\?pid\=1784
8
ggg/batchy/scripts/selectguignols.sh
1#!/bin/sh
2
3
4date="`echo $1 | sed -r "s@(..)(..)(..)@\3\\\\\\\\/\2\\\\\\\\/\1@" `"
5#echo "date : $date"
6#wget -N http://www.canalplus.fr/c-humour/pid1784-c-les-guignols.html
7
8sed -r -n -e "/\\['CONTENT_ID'\\] = /N" \
9    -e "s/^.+\"([0-9]+)\".+\\n.+alt=\"[^\"]*$date[^\"]*\".*\$/\1/p" \
10    < index.php\?pid\=1784
11
ggg/ggg
1#!/bin/bash
2#
3# Copyright 2006 Antoine 'NaPs' Millet <antoine@inaps.org>
4# Copyright 2006 Nicolas 'Batchy'
5#
6# This program is free software; you can redistribute it and/or modify
7# it under the terms of the GNU General Public License as published by
8# the Free Software Foundation; either version 2 of the License, or
9# (at your option) any later version.
10#
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14# GNU General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License
17# along with this program; if not, write to the Free Software
18# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19#
20
21# Configuration :
22
23OUTPUT_DIR=~/video/Guignols
24TMP_DIR=/tmp/
25
26# Fin de la configuration
27
28SCRIPT_VERSION=0.2.2
29
30
31usage () {
32    echo "Usage: ggg [-hvql] [AAMMJJ | today | yesterday] [Fichier de sortie]"
33    echo "Telecharger, et reencoder dans un format compatible avec les tablettes Nokia,"
34    echo "un episode des guignols suivant son jour de diffusion."
35    echo ""
36    echo " -h, --help affiche cette page d'aide"
37    echo " -v, --version affiche la version et quitte"
38    echo " -q, --high-quality encode avec une haute qualite"
39    echo " Recommande pour le Nokia N800"
40    echo " -l, --low-quality encode avec une basse qualite"
41    echo " Recommande pour le Nokia 770"
42    echo " --download-only"
43    echo " N'encode pas le fichier apres telechargement."
44    echo " --encode-only"
45    echo " Encode le fichier deja telecharge avec --download-only"
46    echo ""
47    echo "Par defaut, le script utilise l'option --high-quality."
48    echo "Si -q et -l sont utilisees en meme temps, la derniere selectionnee"
49    echo "sera prise en compte."
50}
51
52version () {
53    echo "ggg (Get GuiGnols) $SCRIPT_VERSION"
54    echo "Ecrit par Antoine 'NaPs' Millet avec quelques contributions"
55    echo "This is free software; see the source for copying conditions. There is NO"
56    echo "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
57}
58
59
60while getopts ":vh-:" opt ; do
61    case $opt in
62        h ) usage ; exit ;;
63        v ) version ; exit ;;
64
65        q ) quality="high" ;;
66        l ) quality="low" ;;
67        - ) case $OPTARG in
68            help ) usage ; exit ;;
69            version ) version ; exit ;;
70
71            high-quality ) quality="high" ;;
72            low-quality ) quality="low" ;;
73            download-only ) encode="no" ;;
74            encode-only ) download="no" ;;
75            * ) echo "Option illegale --$OPTARG" ;;
76        esac ;;
77        ? ) echo "Option illegale -$OPTARG" ;;
78    esac
79done
80shift $(($OPTIND -1))
81
82# Ceci constitue les choix par defaut
83date=${1:-yesterday}
84quality=${quality:-"low"}
85encode=${encode:-"yes"}
86download=${download:-"yes"}
87
88if [ $encode = "no" -a $download = "no" ] ; then
89    echo "Options contradictoires : --download-only --encode-only"
90    exit 1
91fi
92
93case $date in
94    today ) gdate=$(date +%y%m%d) ;;
95    yesterday ) gdate=$(date --date 'yesterday' +%y%m%d) ;;
96    * ) gdate=$date;;
97esac
98
99if [ ! -d $OUTPUT_DIR ] ; then
100    mkdir -p $OUTPUT_DIR
101fi
102output=${2:-"$OUTPUT_DIR/Guignol-$gdate.avi"}
103
104url=http://vipmms.canalplus.fr/canalplus/guignols_"$gdate"_a.wmv?MSWMExt=.asf
105dumpfile=$TMP_DIR/guignols_$gdate.dump
106
107if [ -d $TMP_DIR ] ; then
108    if [ $download = "yes" ] ; then
109        echo "Telechargement du stream..."
110        echo "(Cela prend une dizaine de minutes)"
111        rm -f $dumpfile
112        mplayer -cache 2000 -dumpstream -dumpfile $dumpfile $url > /dev/null
113        if [ ! -s $dumpfile ] ; then
114            echo "Impossible de capturer le stream !"
115            rm -f $dumpfile
116            exit 1
117        fi
118    else
119        if [ ! -r $dumpfile ] ; then
120            echo "Le fichier $dumpfile n'a pas ete telecharge. Impossible d'encoder"
121            exit 1
122        fi
123    fi
124
125
126
127    if [ $encode = "yes" ] ; then
128
129        echo "Re-encodage du fichier..."
130        echo "(Cela peut prendre un peu de temps selon la vitesse du processeur)"
131        case $quality in
132            low ) $(mencoder $dumpfile -oac mp3lame -lameopts abr:br=64:vol=1 -af volnorm -ovc lavc -lavcopts vcodec=mpeg4:dark_mask=0.15:aspect=15/9:vbitrate=256:trell=yes:v4mv=yes:vpass=1 -vf crop=506:304,scale=288:208,eq2=1.4:1.2:0.0:1.4 -idx -ffourcc DIVX -ofps 25.0 -o $output > /dev/null)
133                    $(mencoder $dumpfile -oac mp3lame -lameopts abr:br=64:vol=1 -af volnorm -ovc lavc -lavcopts vcodec=mpeg4:dark_mask=0.15:aspect=15/9:vbitrate=256:trell=yes:v4mv=yes:vpass=2 -vf crop=506:304,scale=288:208,eq2=1.4:1.2:0.0:1.4 -idx -ffourcc DIVX -ofps 25.0 -o $output > /dev/null) ;;
134            high ) $(mencoder $dumpfile -oac mp3lame -lameopts abr:br=64:vol=1 -af volnorm -ovc lavc -lavcopts vcodec=mpeg4:dark_mask=0.15:aspect=15/9:vbitrate=512:trell=yes:v4mv=yes:vpass=1 -vf crop=506:304,scale=352:288,eq2=1.4:1.2:0.0:1.4 -idx -ffourcc DIVX -ofps 25.0 -o $output > /dev/null)
135                    $(mencoder $dumpfile -oac mp3lame -lameopts abr:br=64:vol=1 -af volnorm -ovc lavc -lavcopts vcodec=mpeg4:dark_mask=0.15:aspect=15/9:vbitrate=512:trell=yes:v4mv=yes:vpass=2 -vf crop=506:304,scale=352:288,eq2=1.4:1.2:0.0:1.4 -idx -ffourcc DIVX -ofps 25.0 -o $output > /dev/null) ;;
136        esac
137        if [ -e $output ] ; then
138            echo "L'episode a ete correctement telecharge et encode dans le fichier $output :-)"
139        else
140            echo "Damned, l'encodage n'a pas reussi :-("
141            exit 1
142        fi
143    else
144        echo "Stream telecharge dans le fichier $dumpfile "
145    fi
146else
147    echo "Impossible de localiser le repertoire temporaire"
148    echo "Editez ggg et remplacez la variable TMP_DIR"
149    exit 2
150fi

Archive Download the corresponding diff file

Branches:
master