Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- version=0.8.9
- size=512
- config_FILE=$HOME/.imdb-thumbnailer/config
- video_extensions='
- application@ogg
- application@smil
- application@vnd.rn-realmedia
- application@vnd.rn-realvideo
- application@x-extension-m4a
- application@x-extension-mp4
- application@x-flash-video
- application@x-matroska
- application@x-ms-asf
- application@x-ogg
- application@x-quicktime-media-link
- application@x-shockwave-flash
- application@x-shorten
- application@x-smil
- application@xspf@xml
- audio@x-pn-realaudio
- image@vnd.rn-realpix
- image@vnd.rn-realpix
- misc@ultravox
- video@3gpp
- video@dv
- video@mp4
- video@mpeg
- video@msvideo
- video@quicktime
- video@vnd.divx
- video@vnd.rn-realvideo
- video@x-anim
- video@x-avi
- video@x-flc
- video@x-fli
- video@x-m4v
- video@x-matroska
- video@x-mpeg
- video@x-ms-asf
- video@x-msvideo
- video@x-ms-wmv
- video@x-nsv
- video@x-ogm@ogg
- '
- parse_filename () { :;}
- help ()
- {
- {
- case $LANG in
- es_* )
- echo "
- ACTIVAR/DESACTIVAR EL THUMBNAILER:
- Para completar la instalación es necesario activar el thumbnailer para el usuario actual para thunar y/o nautilus.
- --set-nautilus
- Activa el thumbnailer para nautilus (--unset-nautilus para desactivar)
- --set-thunar
- Activa el thumbnailer para thunar (--unset-thunar para desactivar)
- --set-caja
- Activa el thumbnailer para caja (--unset-caja para desactivar)
- CONFIGURACIÓN:
- archivo: $config_FILE
- imdb-thumbnailer funcionará solo para las rutas especificadas en el archivo de configuración.
- Ejemplo:
- films_path=(
- '/home/user/Films'
- '/home/user/Trailers'
- )
- Siempre se deben usar rutas completas.
- Es posible cambiar el tema agragando lo siguiente:
- theme_name='nombre del tema' (shadow|none)
- OPCIONES:
- -s tamaño entrada salida
- El tamaño máximo es 128, para tamaños más grandes será usado el thumbnailer por defecto.
- --set video1 portada1 video2 portada2 etc...
- Especifica una portada alternativa y llama a la función update (ver --update).
- --update video1 video2 etc...
- Fuerza al explorador de archivos a reconstruir los thumbnails para los videos especificados cambiando sus tiempos de modificación un segundo.
- --remove video1 video2 etc...
- Borra los thumbnails para los videos especificados.
- --name video nombre
- Usa 'nombre' para buscar la portada y establecer la miniatura para 'video'.
- "
- ;;
- de_* ) # translated by thoughtcrime
- echo "
- DEN THUMBNAILER (DE)AKTIVIEREN:
- Um die Installation zu vervollständigen, muss der Thumbnailer für den aktuellen Benutzer bei Nautilus und/oder Thunar aktiviert werden.
- --set-nautilus
- Aktiviert den Thumbnailer für Nautilus (deaktivieren mit --unset-nautilus)
- --set-thunar
- Aktiviert den Thumbnailer für Thunar (deaktivieren mit --unset-thunar)
- --set-caja
- Aktiviert den Thumbnailer für Caja (deaktivieren mit --unset-caja)
- KONFIGURATION:
- Datei: $config_FILE
- Imdb-Thumbnailer lädt nur Film-Poster als Vorschaubilder in den Pfaden herunter, die in der Konfigurationsdatei eingetragen wurden.
- Beispiele:
- films_path=(
- '/home/user/Filme'
- '/home/user/Trailer'
- )
- Das Thema kann wie folgt geändert werden:
- theme_name='Name des Themas' (shadow|none)
- OPTIONEN:
- -s Größe input output
- Der größte Wert für -s ist 128.
- --set video1 cover1 video2 cover2 etc...
- Setzt eigene Cover als Vorschaubilder und ruft die Update-Funktion auf (siehe auch --update).
- --update video1 video2 etc...
- Zwingt den Dateibrowser neue Vorschaubilder für die genannten Videos zu erstellen, indem die letzte Bearbeitungszeit um eine Sekunde geändert wird.
- --remove video1 video2 etc...
- Löscht die Vorschaubilder für entsprechende Videodateien.
- --name Video Suchbegriff
- Für 'Video' 'Suchbegriff' verwenden, um bessere Ergebnisse zu finden.
- "
- ;;
- * )
- echo "
- SET/UNSET THE THUMBNAILER:
- To complete the installation you must set the thumbnailer for the current user for thunar and/or nautilus.
- --set-nautilus
- Sets the thumbnailer for nautilus (use --unset-nautilus to remove)
- --set-thunar
- Sets the thumbnailer for thunar (use --unset-thunar to remove)
- --set-caja
- Sets the thumbnailer for caja (use --unset-caja to remove)
- CONFIGURATION:
- file: $config_FILE
- imdb-thumbnailer will work only for the paths specified in the configuration file.
- Example:
- films_path=(
- '/home/user/Films'
- '/home/user/Trailers'
- )
- Always use full paths.
- You can change the theme adding the following:
- theme_name='name of the theme' (shadow|none)
- OPTIONS:
- -s size input output
- Maximun size is 128, else the default thumbnailer will be used.
- --set video1 cover1 video2 cover2 etc...
- Set custom covers and call the update function (see --update).
- --update video1 video2 etc...
- Force the filebrowser to rebuild the thumbnails for the specified videos by changing their modification time 1 second.
- --remove video1 video2 etc...
- Remove thumbnails for the specified videos.
- --name video name
- Set the thumbnail for 'video' using 'name' to search for the cover.
- "
- esac
- } | cut -c6- | fmt
- }
- set_thumbnail ()
- {
- file_path=$1
- grabber_picture=$2
- if [[ -f "$file_path" && -n $grabber_picture ]]; then
- file_time_size=$(stat --format=%y-%s "$file_path")
- file_time_size=${file_time_size//.*-/-}
- cover_name=$file_time_size
- cover_path=$HOME/.imdb-thumbnailer/covers
- if ! [[ -d "$cover_path" ]] ; then
- mkdir -p "$cover_path"
- fi
- #ffmpegthumbnailer -i "$grabber_picture" -thumbnail -s 256 -o "$cover_path/$cover_name.png"
- #ffmpeg -i "$grabber_picture" -vframes 1 "$cover_path/$cover_name.png"
- #ffmpeg -i "$grabber_picture" "$cover_path/$cover_name.png"
- convert "$grabber_picture" -thumbnail ${size}x${size} "$cover_path/$cover_name.png"
- update_thumbnail "$file_path"
- elif ! [[ -f "$file_path" ]]; then
- echo "ERROR:\"$file_path\" does not exist"
- exit 1
- else
- echo "ERROR: no cover for: $file_path"
- exit 1
- fi
- }
- remove_thumbnail ()
- {
- thumb2delete=$(echo "$1" | sed "s|'|\\\'|g" )
- thumb2delete_URI=$(python2 -c "import gnomevfs; print gnomevfs.get_uri_from_local_path('$thumb2delete')")
- MD5=$(echo -n "$thumb2delete_URI" | md5sum) MD5=${MD5%% *}
- remove_thumbnail_files $MD5
- #delete thunar thumbnail:
- if [[ "$(echo "$1" | egrep ':|,' )" ]]; then
- thumb2delete_URI=${thumb2delete_URI//%2C/,} thumb2delete_URI=${thumb2delete_URI//%3A/:}
- MD5=$(echo -n "$thumb2delete_URI" | md5sum) MD5=${MD5%% *}
- remove_thumbnail_files $MD5
- fi
- }
- remove_thumbnail_files ()
- {
- local folder
- for folder in fail large normal
- {
- if [[ -f $HOME/.cache/thumbnails/$folder/$1.png ]]; then
- rm $HOME/.cache/thumbnails/$folder/$1.png
- echo "removed: $HOME/.cache/thumbnails/$folder/$1.png"
- fi
- }
- }
- update_thumbnail ()
- {
- file_path=$1
- if [[ -f "$file_path" ]]; then
- file_time_size=$(stat --format=%y-%s "$file_path")
- file_time_size=${file_time_size//.*-/-}
- file_time=${file_time_size%-*}
- file_size=${file_time_size##*-}
- if [[ $file_time ]]; then
- cover_name=$file_time_size
- cover_path=$HOME/.imdb-thumbnailer/covers
- second=${file_time:18:19}
- case $second in
- [13579] ) second=$((second-1)) ;;
- * ) second=$((second+1)) ;;
- esac
- incomplete_time=${file_time:0:18}
- new_cover_name=$incomplete_time$second-$file_size
- if [[ -f $cover_path/$cover_name.png ]]; then
- mv "$cover_path/$cover_name.png" "$cover_path/$new_cover_name.png"
- fi
- touch "$file_path" -d "$incomplete_time$second"
- fi
- else
- echo "ERROR:\"$file_path\" does not exist"
- exit 1
- fi
- }
- default_video_thumbnailer ()
- # {
- # if [[ $(type -fp gnome-video-thumbnailer) ]]; then
- # totem-video-thumbnailer -m -s $size -i "$SOURCE_url" -o "$OUTPUT_path"
- # elif [[ $(type -fp totem-video-thumbnailer) ]]; then
- # totem-video-thumbnailer -m -s $size -i "$SOURCE_url" -o "$OUTPUT_path"
- # elif [[ $(type -fp mplayer-video-thumb.sh) ]]; then
- # ffmpegthumbnailer -m -s $size -i "$SOURCE_url" -o "$OUTPUT_path" -f
- # elif [[ $(type -fp ffmpegthumbnailer) ]]; then
- # ffmpegthumbnailer -m -s $size -i "$SOURCE_url" -o "$OUTPUT_path" -f
- # fi
- # }
- {
- if [[ $(type -fp ffmpegthumbnailer) ]]; then
- ffmpegthumbnailer -m -s $size -i "$SOURCE_url" -o "$OUTPUT_path" -f
- fi
- }
- restart_nautilus ()
- {
- echo -n "Should I restart nautilus? (This will close all open windows) [yN] "
- read answer
- if [ $answer:x = y:x ]; then
- nautilus -q
- else
- echo "The changes will not be done until you restart nautilus with:"
- echo "nautilus -q"
- fi
- }
- restart_caja ()
- {
- echo -n "Should I restart caja? (This will close all open windows) [yN] "
- read answer
- if [ $answer:x = y:x ]; then
- caja -q
- else
- echo "The changes will not be done until you restart c with:"
- echo "caja -q"
- fi
- }
- init_configfile ()
- {
- if ! [[ -f $HOME/.imdb-thumbnailer/config ]]; then
- echo
- echo "Please edit $config_FILE"
- echo "and insert your Video paths there."
- echo "Always use full paths!"
- mkdir -p $HOME/.imdb-thumbnailer
- {
- echo 'films_path[0]="$HOME/Trailers"'
- echo 'films_path[1]='
- echo 'films_path[2]='
- echo 'films_path[3]='
- } > $config_FILE
- fi
- }
- set_thumbnailer_for_nautilus ()
- {
- local configFile=$HOME/.local/share/thumbnailers/imdb.thumbnailer
- mkdir -p ${configFile%/*}
- if [[ $1 = -r ]];then
- thumbnailer='/usr/bin/totem-video-thumbnailer -s %s %u %o'
- rm $configFile
- else
- rmdir $configFile &>/dev/null #fixes bug
- thumbnailer="$(which imdb-thumbnailer) -s %s %u %o"
- {
- echo '[Thumbnailer Entry]'
- echo 'TryExec=/usr/bin/imdb-thumbnailer'
- echo 'Exec=/usr/bin/imdb-thumbnailer -s %s %u %o'
- echo 'MimeType=application/mxf;application/ogg;application/ram;application/sdp;application/vnd.ms-wpl;application/vnd.rn-realmedia;application/x-extension-m4a;application/x-extension-mp4;application/x-flash-video;application/x-matroska;application/x-netshow-channel;application/x-ogg;application/x-quicktimeplayer;application/x-shorten;image/vnd.rn-realpix;image/x-pict;misc/ultravox;text/x-google-video-pointer;video/3gpp;video/dv;video/fli;video/flv;video/mp2t;video/mp4;video/mp4v-es;video/mpeg;video/msvideo;video/ogg;video/quicktime;video/vivo;video/vnd.divx;video/vnd.rn-realvideo;video/vnd.vivo;video/webm;video/x-anim;video/x-avi;video/x-flc;video/x-fli;video/x-flic;video/x-flv;video/x-m4v;video/x-matroska;video/x-mpeg;video/x-ms-asf;video/x-ms-asx;video/x-msvideo;video/x-ms-wm;video/x-ms-wmv;video/x-ms-wmx;video/x-ms-wvx;video/x-nsv;video/x-ogm+ogg;video/x-theora+ogg;video/x-totem-stream;audio/x-pn-realaudio;audio/3gpp;audio/ac3;audio/AMR;audio/AMR-WB;audio/basic;audio/midi;audio/mp2;audio/mp4;audio/mpeg;audio/ogg;audio/prs.sid;audio/vnd.rn-realaudio;audio/x-aiff;audio/x-ape;audio/x-flac;audio/x-gsm;audio/x-it;audio/x-m4a;audio/x-matroska;audio/x-mod;audio/x-mp3;audio/x-mpeg;audio/x-ms-asf;audio/x-ms-asx;audio/x-ms-wax;audio/x-ms-wma;audio/x-musepack;audio/x-pn-aiff;audio/x-pn-au;audio/x-pn-wav;audio/x-pn-windows-acm;audio/x-realaudio;audio/x-real-audio;audio/x-sbc;audio/x-speex;audio/x-tta;audio/x-wav;audio/x-wavpack;audio/x-vorbis;audio/x-vorbis+ogg;audio/x-xm;application/x-flac;'
- } > $configFile
- fi
- for i in $video_extensions; do
- echo Setting Key for $i
- gconftool-2 -s "/desktop/gnome/thumbnailers/$i"/command -t string "$thumbnailer"
- gconftool-2 -s "/desktop/gnome/thumbnailers/$i"/enable -t boolean 'true'
- done
- restart_nautilus
- [[ $1 != -r ]] && init_configfile
- }
- set_thumbnailer_for_caja ()
- {
- local configFile=$HOME/.local/share/thumbnailers/imdb.thumbnailer
- mkdir -p ${configFile%/*}
- if [[ $1 = -r ]];then
- thumbnailer='/usr/bin/totem-video-thumbnailer -s %s %u %o'
- rm $configFile
- else
- rmdir $configFile &>/dev/null #fixes bug
- thumbnailer="$(which imdb-thumbnailer) -s %s %u %o"
- {
- echo '[Thumbnailer Entry]'
- echo 'TryExec=/usr/bin/imdb-thumbnailer'
- echo 'Exec=/usr/bin/imdb-thumbnailer -s %s %u %o'
- echo 'MimeType=application/mxf;application/ogg;application/ram;application/sdp;application/vnd.ms-wpl;application/vnd.rn-realmedia;application/x-extension-m4a;application/x-extension-mp4;application/x-flash-video;application/x-matroska;application/x-netshow-channel;application/x-ogg;application/x-quicktimeplayer;application/x-shorten;image/vnd.rn-realpix;image/x-pict;misc/ultravox;text/x-google-video-pointer;video/3gpp;video/dv;video/fli;video/flv;video/mp2t;video/mp4;video/mp4v-es;video/mpeg;video/msvideo;video/ogg;video/quicktime;video/vivo;video/vnd.divx;video/vnd.rn-realvideo;video/vnd.vivo;video/webm;video/x-anim;video/x-avi;video/x-flc;video/x-fli;video/x-flic;video/x-flv;video/x-m4v;video/x-matroska;video/x-mpeg;video/x-ms-asf;video/x-ms-asx;video/x-msvideo;video/x-ms-wm;video/x-ms-wmv;video/x-ms-wmx;video/x-ms-wvx;video/x-nsv;video/x-ogm+ogg;video/x-theora+ogg;video/x-totem-stream;audio/x-pn-realaudio;audio/3gpp;audio/ac3;audio/AMR;audio/AMR-WB;audio/basic;audio/midi;audio/mp2;audio/mp4;audio/mpeg;audio/ogg;audio/prs.sid;audio/vnd.rn-realaudio;audio/x-aiff;audio/x-ape;audio/x-flac;audio/x-gsm;audio/x-it;audio/x-m4a;audio/x-matroska;audio/x-mod;audio/x-mp3;audio/x-mpeg;audio/x-ms-asf;audio/x-ms-asx;audio/x-ms-wax;audio/x-ms-wma;audio/x-musepack;audio/x-pn-aiff;audio/x-pn-au;audio/x-pn-wav;audio/x-pn-windows-acm;audio/x-realaudio;audio/x-real-audio;audio/x-sbc;audio/x-speex;audio/x-tta;audio/x-wav;audio/x-wavpack;audio/x-vorbis;audio/x-vorbis+ogg;audio/x-xm;application/x-flac;'
- } > $configFile
- fi
- for i in $video_extensions; do
- echo Setting Key for $i
- gconftool-2 -s "/desktop/mate/thumbnailers/$i"/command -t string "$thumbnailer"
- gconftool-2 -s "/desktop/mate/thumbnailers/$i"/enable -t boolean 'true'
- done
- restart_caja
- [[ $1 != -r ]] && init_configfile
- }
- set_thumbnailer_for_thunar ()
- {
- local desktopFile=$HOME/.local/share/thumbnailers/imdb.desktop
- mkdir -p ${configFile%/*}
- if [[ $1 = -r ]]; then
- rm $desktopFile
- else
- mkdir -p $HOME/.local/share/thumbnailers &>/dev/null
- {
- echo '[Desktop Entry]'
- echo 'Version=1.0'
- echo 'Encoding=UTF-8'
- echo 'Type=X-Thumbnailer'
- echo 'Name=imdb'
- echo -n 'MimeType='
- for i in $video_extensions; do
- echo -n ${i//@/\/}\;
- done
- echo ''
- echo "X-Thumbnailer-Exec=$(which imdb-thumbnailer) -s %s %u %o"
- } > $desktopFile
- echo "> $desktopFile"
- init_configfile
- fi
- }
- get_query ()
- {
- declare -l name=$*
- name=${name##*/}
- name=${name//.[5].[1]} # только для HDRezka
- name=${name//.[2].[0]} # только для HDRezka
- name=${name%.???}
- name=${name//[_\.\-() ]/+}
- name=${name//s[0-9][0-9]}
- name=${name//e[0-9][0-9]}
- #name=${name//[0-9][0-9]} #надо проверить
- name=${name//cd[1-9]}
- name=${name//[1-9]of[1-9]}
- name=${name//fps}
- name=${name//webdl}
- name=${name//webrip}
- name=${name//dvdrip}
- name=${name//dvdscr}
- name=${name//axxo}
- name=${name//fxg}
- name=${name//divx}
- name=${name//xvid}
- name=${name//mkv}
- name=${name//720p}
- name=${name//720}
- name=${name//1080p}
- name=${name//1080i}
- name=${name//[0-9][0-9][0-9][0-9]} #типа год
- name=${name//h+264}
- name=${name//x264}
- name=${name//h264}
- name=${name//264}
- name=${name//x265}
- name=${name//hddvd}
- name=${name//hdrezka}
- name=${name//hdrip}
- name=${name//hd}
- name=${name//blueray}
- name=${name//brrip}
- name=${name//bdrip}
- name=${name//bd}
- name=${name//tvrip}
- name=${name//yify}
- name=${name//aac}
- name=${name//ac3}
- name=${name//nf}
- name=${name//rip}
- name=${name//lq}
- name=${name//tvshows}
- name=${name//selezen}
- name=${name//studio}
- name=${name//nnmclub}
- name=${name//hevc}
- name=${name//ужасы}
- name=${name//фантастика}
- name=${name//боевик}
- name=${name//приключения}
- name=${name//триллер}
- name=${name//детектив}
- name=${name//rus}
- name=${name//eng}
- name=${name//lostfilm}
- name=${name//ideafilm}
- name=${name//new}
- name=${name//tv}
- name=${name//".ts"}
- name=${name//#[0-9][0-9]}
- # name=${name//#[0-9]}
- name=${name//'open+matte'}
- name=${name//"[nolimits+team]"}
- name=${name//"ay+oasis+nnm+club"}
- query=$name
- parse_filename
- }
- get_id ()
- {
- local search=$*
- while rdom; do
- if [[ $E = h3* ]] && rdom && [[ $E = *https://????imdb.com/title/tt* ]]; then
- var href = this href
- href=${href%/*}/
- href=https:${href#*https:}
- get_id_from_url ${href}
- return
- fi
- done < <(wget -U firefox -qO - "google.com/search?q=site:imdb.com/title+$search")
- #done < <(wget -U firefox -qO - "google.com/search?q=title%20site:imdb.com")
- echo 'get_id_from_google'
- echo "href ${href}"
- #get_id_from_imdb2 "$*"
- [[ $id ]] || get_id_from_imdb "$*" && get_id_from_bing "$*" && get_id_from_imdb2 "$*"
- }
- get_id_from_bing ()
- {
- local search=$*
- while rdom; do
- if [[ $E = h2* ]] && rdom && [[ $E = *https://????imdb.com/title/tt* ]]; then
- var href = this href
- href=${href%/*}/
- href=https:${href#*https:}
- get_id_from_url ${href}
- return
- fi
- done < <(wget -U firefox -qO - "bing.com/search?q=site:imdb.com/title+$search")
- #done < <(wget -U firefox -qO - "bing.com/search?q=title%20site:imdb.com")
- echo 'get_id_from_bing'
- echo "href ${href}"
- }
- get_id_from_imdb ()
- {
- local search=$*
- while rdom; do
- if [[ $E = h1* ]] && rdom && [[ $E = *https://????imdb.com/title/tt* ]]; then
- var href = this href
- echo "href= ${href}"
- href=${href%/*}/
- echo "href= ${href}"
- href=https:${href#*https:}
- echo "href= ${href}"
- get_id_from_url ${href}
- return
- fi
- done < <(wget -U firefox -qO - "imdb.com/find?q=$search")
- # #done < <(wget -U firefox -qO - "bing.com/search?q=title%20site:imdb.com")
- echo 'get_id_from_imdb'
- echo "href ${href}"
- echo "link imdb.com/find?q=$search"
- }
- get_id_from_imdb2 () {
- echo "get_id_from_imdb2"
- local search=$*
- id=$(wget -U firefox -qO - "imdb.com/find?q=$search" | sed -e '/Titles<\/h3>/,/findMoreMatches/!d' | grep -E -w -o "\/title\/[a-zA-Z0-9]+\/" | head -1 | awk -F"/" '{ print $3}')
- echo "id= $id"
- echo "imdb.com/find?q=$search"
- }
- get_id_from_url ()
- {
- local IFS=/
- set -- $1
- case $* in
- https:*imdb.*title*tt* ) id=$5
- ;; *title*tt* ) id=$3
- ;; tt[0-9]* ) id=$1
- ;; * | "" ) return 1
- esac
- echo 'get_id_from_url'
- echo 'id5: $id'
- }
- var () { local return ; "${@:3}" ; eval $1$2\$return;}
- this ()
- {
- return=${E#* }
- eval local ${return%/}
- return=${!1}
- }
- rdom () { local IFS=\> ; read -d \< E C ;}
- get_grabber_picture ()
- {
- if [[ $1 ]]; then
- id=$1
- id=${id%%:*}
- while rdom; do
- #if [[ $E = *'class="poster'* ]]; then
- if [[ $E = *'class="poster"'* ]]; then
- rdom;rdom;
- if [[ $E != *add_photo_text* ]]; then
- var icon = this src
- fi
- break
- fi
- done < <(wget -U firefox -qO - "https://www.imdb.com/title/$id/")
- [[ $icon ]] && grabber_picture=${icon%@*}@.png #${icon%@@*}@@.png #_V1._SX512_SY512_.png
- #[[ $icon ]] && grabber_picture=${icon%@@*}@@._V1._SX${size}_SY${size}_.png
- fi
- }
- # get_grabber_picture ()
- # {
- # if [[ $1 ]]; then
- # id=$1
- # id=${id%%:*}
- # while rdom; do
- # if [[ $E = *'og="image"'* ]]; then
- # rdom;rdom;
- # if [[ $E != *add_photo_text* ]]; then
- # var icon = this content
- # fi
- # break
- # fi
- # done < <(wget -U firefox -qO - "https://www.imdb.com/title/$id/mediaviewer/rm1632284417")
- # [[ $icon ]] && grabber_picture=${icon%@@*}@@._V1._SX512_SY512_.png
- # #[[ $icon ]] && grabber_picture=${icon%@@*}@@._V1._SX${size}_SY${size}_.png
- # fi
- # }
- get_custom_cover ()
- {
- file_time_size=$(stat --format=%y-%s "$SOURCE_pathname") file_time_size=${file_time_size//.*-/-}
- cover_name=$file_time_size
- cover_path=$HOME/.imdb-thumbnailer/covers
- if [[ -f $cover_path/$cover_name.png ]]; then
- grabber_picture=$cover_path/$cover_name.png
- fi
- }
- check_path ()
- {
- #check if it match the current folder:
- for i in "${films_path[@]}"; do
- if [[ "$1" = "$i/"* ]]; then
- return 0
- folder2filter=yes
- break
- fi
- done
- return 1
- }
- get_cover ()
- {
- #imdb-thumbnailer:
- if [[ ! $grabber_picture ]]; then
- if [[ -z $id ]]; then
- get_query "$SOURCE_url"
- get_id "$query"
- fi
- get_grabber_picture $id
- if [[ -z $grabber_picture ]]; then
- default_video_thumbnailer
- exit
- fi
- fi
- }
- make_cover ()
- {
- case $theme_name in
- shadow )
- size=$(( $size - 12 ))
- convert \
- "$grabber_picture" -thumbnail ${size}x${size} \
- \( +clone -background black -shadow 55x3+3+3 -channel A -evaluate multiply 2 +channel \) \
- +swap +repage -gravity center -geometry -0-2 -composite \
- "$OUTPUT_path.png"
- #ffmpegthumbnailer -i "$grabber_picture" -thumbnail -s 512 -o "$OUTPUT_path.png" -f
- echo "OUTPUT_path: $OUTPUT_path"
- echo "OUTPUT_path.png: $OUTPUT_path.png"
- ;;
- movie_strip )
- #convert "$grabber_picture" -thumbnail ${size}x${size} "$OUTPUT_path.png"
- ffmpegthumbnailer -i "$grabber_picture" -thumbnail -s 512 -o "$OUTPUT_path.png" -f
- ;;
- * )
- convert "$grabber_picture" -thumbnail ${size}x${size} "$OUTPUT_path.png"
- ;;
- esac
- #cp "$OUTPUT_path.png" "/home/ypp/.cache/thumbnails/large"
- mv "$OUTPUT_path.png" "$OUTPUT_path"
- }
- get_SOURCE_pathname ()
- {
- SOURCE_pathname=${1//\'/\\\'}
- #echo "SOURCE_pathname1: $SOURCE_pathname"
- SOURCE_pathname=$(python2 -c "from urllib import url2pathname; print url2pathname('$SOURCE_pathname')")
- #echo "SOURCE_pathname2: $SOURCE_pathname"
- SOURCE_pathname=${SOURCE_pathname#file://}
- #echo "SOURCE_pathname3: $SOURCE_pathname"
- }
- init ()
- {
- if [[ -z $1 ]]; then
- help
- exit
- fi
- [[ -f $config_FILE ]] && . $config_FILE
- while [[ $1 ]]; do
- case $1 in
- -s ) shift
- #size=$1
- size=512
- ;;
- -s | --set ) shift
- while [[ $1 ]]; do
- set_thumbnail "$1" "$2"
- shift 2
- done
- exit
- ;;
- -r | --remove ) shift
- while [[ $1 ]]; do
- remove_thumbnail "$1"
- shift
- done
- exit
- ;;
- -u | --update | --refresh )
- shift
- while [[ $1 ]]; do
- update_thumbnail "$1"
- shift
- done
- exit
- ;;
- -n | --name )
- shift
- get_id "$2"
- #get_id "$query"
- get_grabber_picture $id
- set_thumbnail "$1" "$grabber_picture"
- exit
- ;;
- --set-nautilus )
- set_thumbnailer_for_nautilus
- exit
- ;;
- --unset-nautilus )
- set_thumbnailer_for_nautilus -r
- exit
- ;;
- --set-thunar )
- set_thumbnailer_for_thunar
- exit
- ;;
- --unset-thunar )
- rm $HOME/.local/share/thumbnailers/imdb.desktop && echo "rm $HOME/.local/share/thumbnailers/imdb.desktop" || echo "ERROR: not set"
- exit
- ;;
- --set-caja )
- set_thumbnailer_for_caja
- exit
- ;;
- --unset-caja )
- set_thumbnailer_for_caja -r
- exit
- ;;
- -t | --theme )
- shift
- if [ -f "$themes_PATH/$1" ] ; then
- theme_name=$1
- else
- echo "$1 theme does not exist"
- exit 1
- fi
- ;;
- --test)
- file=$2
- if check_path "$file"; then
- echo "Path IS in the list"
- else
- echo "Path NOT in the list"
- fi
- SOURCE_url=${file//\'/\\\'}
- #SOURCE_url=file://$(python2 -c "from urllib import pathname2url; print pathname2url('$SOURCE_url')")
- SOURCE_url=${SOURCE_url#file://}
- echo "SOURCE_url: $SOURCE_url"
- get_SOURCE_pathname "$SOURCE_url"
- echo "SOURCE_pathname: $SOURCE_pathname"
- get_query "$SOURCE_url"
- echo "query: $query"
- get_id "$query"
- echo "id: $id"
- echo "url: https://www.imdb.com/title/$id/"
- get_grabber_picture $id
- echo "grabber_picture: $grabber_picture"
- #lsix "$grabber_picture" || echo "grabber_picture does not exist"
- set_thumbnail "$2" "$grabber_picture"
- exit
- ;;
- --test-grabber)
- id=tt1831804
- #id=tt2494362
- get_grabber_picture $id
- echo "grabber_picture: $grabber_picture"
- exit
- ;;
- --help | -h ) help
- exit
- ;;
- --version | -v )
- echo $version
- exit
- ;;
- * ) if [[ -z $SOURCE_url ]]; then
- SOURCE_url=$1
- elif [[ -z $OUTPUT_path ]]; then
- OUTPUT_path=$1
- else
- echo "$1 is invalid"
- exit 1
- fi
- esac
- shift
- done
- #decode filename:
- get_SOURCE_pathname "$SOURCE_url"
- get_custom_cover
- if [[ ! $grabber_picture ]]; then
- if ! check_path "$SOURCE_pathname"; then
- default_video_thumbnailer
- exit
- fi
- fi
- get_cover
- make_cover
- }
- init "$@"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement