Guest User

Untitled

a guest
Jan 21st, 2018
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.70 KB | None | 0 0
  1. MP=`which mplayer`
  2. TOT=`which totem`
  3. if [ -z $TOT ] && [ -z $MP ]; then
  4.     zenity --error --title "Videos" --text "No se encuentra ni Mplayer ni Totem en el sistema"
  5.     exit 1
  6. fi
  7. if [ -z $TOT ] || [ -z $MP ]; then
  8.     if [ -z $TOT ]; then
  9.         echo "Totem no se encuentra en el sistema, se usa mplayer"
  10.         REP=$MP
  11.     elif [ -z $M ]; then
  12.         echo "Mplayer no se encuentra en el sistema, se usa totem"
  13.         REP=$TOT
  14.     fi
  15. else REP=$TOT
  16. fi
  17. #!/bin/bash
  18.  
  19. DIR="$HOME/videosget"
  20.  
  21. ####Vemos la cantidad de archivos
  22. let FILES=`lsof -X | grep -i flash | grep tmp | wc -l`
  23.  
  24. ###Definimos una funcion que nos va a dar la lista de archivos
  25. function LISTA {
  26.     lsof -X | grep -i flash | grep tmp | awk '{print $2, $4}' | tr -d [a-zA-Z] | awk '{print "/proc/"$1"/fd/"$2}'
  27. }
  28.  
  29. ####Definimos la funcion que nos va a permitir seleccionar los archivos para reproducir/guardar
  30. function SEL {
  31.     SELECCION=`LISTA | zenity --text "Elija los videos deseados" --multiple --list --title "Videos" --column "videos" | tr "|" "\n"`
  32.     if [ -z "$SELECCION" ]; then ##Verificamos que se haya seleccionado algun archivo, de no ser asi sale con un error
  33.         zenity --error --title "Videos" --text "Debe elegir al menos un video"
  34.         exit 1
  35.     fi
  36. }
  37.  
  38. function NOMBRE {
  39.     FILE=$DIR/`zenity --entry --title "Videos" --text "Ingrese el nombre para el archivo $i"`.flv
  40.     while [ -e "$FILE" ]; do
  41.         zenity --question --title "Videos" --text "El archivo $FILE ya existe\nDesea Seleccionar otro nombre?"
  42.             if [ 0 == $? ]; then
  43.                 FILE=$DIR/`zenity --entry --title "Videos" --text "Ingrese el nombre del archivo $i"`.flv
  44.             else
  45.                 zenity --question --title "Videos" --text "Desea sobreescribir $FILE ?"
  46.                 if [ 0 == $? ]; then
  47.                    break
  48.                 else
  49.                     exit 0
  50.                 fi
  51.             fi
  52.         done
  53.     }
  54.  
  55. #Creamos el directorio videosget (en caso de no existir)
  56. if [ ! -d $DIR ]
  57. then
  58.     mkdir $DIR
  59. fi
  60. if [ $FILES -gt 0 ]
  61. then
  62.  
  63.     ANS=$(zenity  --list  --title "Videos" --text "Elija la tarea a realizar" --radiolist  --column "  " --column "opcion" TRUE "Ver_videos" FALSE Guardar)
  64.     if [ -z $ANS ]; then
  65.         exit 0
  66.     elif [ $ANS == Guardar ]; then
  67.            SEL
  68.            #Creamos un bucle for para pedir nombre de cada archivo
  69.            for i in $SELECCION
  70.            do
  71.                NOMBRE
  72.                cp  $i  "$FILE"
  73.          done
  74.          zenity --info --title "Videos" --text "Los archivos se guardaron en $DIR" --title "Videos"
  75.     else
  76.     SEL
  77.     $MP $SELECCION
  78.     fi
  79. else
  80.     zenity --error --title "Videos" --text "No se encontraron videos"
  81. fi
Add Comment
Please, Sign In to add comment