core.sh 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. _ENTER()
  2. {
  3. echo -e '\e[31;1m'
  4. read -p $'\nEnter para prosseguir.'
  5. echo -e '\e[m'
  6. }
  7. ############################################################
  8. # Listagem de Categorias/Fichas no Banco
  9. ############################################################
  10. _DATABASE()
  11. {
  12. local inc='0'
  13. local category
  14. local show
  15. local directory
  16. local archive_show
  17. echo -e "Opções Disponiveis no ${NAME}\n"
  18. for show in *; do
  19. if [[ "$inc" -eq '0' ]]; then
  20. echo -e "[ "$inc" ] ${cyan_}MENU PRINCIPAL${end_}"
  21. inc=$(( $inc + 1 ))
  22. fi
  23. echo "[ $inc ] ${show^}"
  24. directory[$inc]="${show}" # Capturando indice
  25. inc=$(( $inc + 1 ))
  26. done
  27. echo -e '\e[36;1m'
  28. read -p $'\nSelecione Qual Categoria você deseja acessar: ' category
  29. echo -e '\e[m'
  30. # O diretório existe no banco?
  31. if [[ "$category" = '0' ]]; then
  32. popd &>/dev/null
  33. return 32
  34. fi
  35. if [[ ! -d "${directory[$category]}" ]]; then
  36. echo "A categoria não existe."
  37. _ENTER
  38. popd &>/dev/null
  39. return 1
  40. fi
  41. while :; do
  42. # filmes disponiveis na categoria.
  43. echo -e "\n########################### ${directory[$category]^}"
  44. local inc='0'
  45. pushd "${directory[$category]}" &>/dev/null
  46. for archive_show in *; do
  47. if [[ "$inc" -eq '0' ]]; then
  48. echo -e "[ "$inc" ] ${cyan_}VOLTAR${end_}"
  49. inc=$(( $inc + 1 ))
  50. fi
  51. print_archive_show="${archive_show//_/ }" # Trocando _ por Espaço.
  52. echo "[ $inc ] ${print_archive_show^}"
  53. archive[$inc]="${archive_show}" # Capturando indice
  54. inc=$(( $inc + 1 ))
  55. done
  56. echo -e '\e[36;1m'
  57. read -p $'O que você deseja assistir?: ' watch_now
  58. echo -e '\e[m'
  59. if [[ "$watch_now" = 0 ]]; then
  60. popd &>/dev/null
  61. break
  62. elif [[ -z "$watch_now" ]]; then
  63. continue
  64. elif [[ ! -e "${archive[$watch_now]}" ]]; then
  65. echo "Não encontrei esse filme."
  66. continue
  67. fi
  68. ( # Abertura subshell para não sujar ambiente.
  69. source "${archive[$watch_now]}"
  70. # Chamando a função para tocar o video.
  71. _PLAY "$title_name" "$classification" "$url_video" "$description"
  72. )
  73. done
  74. }
  75. ############################################################
  76. # Função para tocar o padrão, se em todas os gates
  77. # o video se mostrar disponivel o streamming começa.
  78. ############################################################
  79. _PLAY()
  80. {
  81. local title_name="$1"
  82. local classification="$2"
  83. local url_video="$3"
  84. local description="$4"
  85. echo "======================================================================"
  86. echo -e "${blue_}Você está Assistindo:${end_} $title_name"
  87. echo -e "${blue_}Classificação: ${end_} $classification"
  88. echo -e "${blue_}Descrição:${end_}"
  89. echo "$description"
  90. echo -e "=======================================================================\n"
  91. echo -e "
  92. ############# OPÇÕES DO PLAYER #############
  93. ${cyan_}'q/ESC'${end_} Retornar.
  94. ${cyan_}'f'${end_} Full Screen.${end_}
  95. ${cyan_}'p'${end_} Pausar.${end_}
  96. ${cyan_}'9'${end_} Aumentar Volume.
  97. ${cyan_}'0'${end_} Abaixar Volume
  98. ${cyan_}'Direcional Direita'${end_} Avança 10 segundos.
  99. ${cyan_}'Direcional Esquerda'${end_} Retrocede 10 segundos.
  100. "
  101. youtube-dl -q "$url_video" -o - | mplayer - &>/dev/null
  102. }