Advertisement
metalx1000

Movie/TV Search and Streaming

Apr 6th, 2023
1,453
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.96 KB | None | 0 0
  1. #!/bin/bash
  2. ######################################################################
  3. #Copyright (C) 2023  Kris Occhipinti
  4. #https://filmsbykris.com
  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 version 3 of the License.
  9.  
  10. #This program is distributed in the hope that it will be useful,
  11. #but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. #GNU General Public License for more details.
  14.  
  15. #You should have received a copy of the GNU General Public License
  16. #along with this program.  If not, see <http://www.gnu.org/licenses/>.
  17. ######################################################################
  18. # Movie/TV Search
  19.  
  20. tmdb="https://www.themoviedb.org/search?language=en-US&query="
  21. vid_url="https://www.2embed.to/embed/tmdb/"
  22.  
  23. [[ $1 ]] && q="$*" || read -p "Enter Movie or TV Show: " q
  24. [[ $q ]] || exit
  25.  
  26. function get_list(){
  27.   wget "${tmdb}${q}" -qO-|
  28.     grep 'class="result"'|
  29.     grep '</a>'|
  30.     cut -d\" -f 10,11|
  31.     grep '<h2>'|
  32.     sed 's/?language=en-US"><h2>/|/g'|
  33.     cut -d\< -f1|
  34.     recode html..ascii
  35. }
  36.  
  37. function get_episode(){
  38.   read -p "Which Season [example: 1]: " season
  39.   [[ $season ]] || season="1"
  40.   [[ $season =~ $re ]] || season="1"
  41.  
  42.   read -p "Which Episode [example: 1]: " episode
  43.   [[ $episode ]] || episode="1"
  44.   [[ $episode =~ $re ]] || episode="1"
  45.  
  46.   echo "tv?id=${id}&s=${season}&e=${episode}"
  47. }
  48.  
  49. result="$(get_list|fzf --prompt "Search for match: ")"
  50. [[ $result ]] || exit
  51.  
  52. type="$(echo $result|cut -d\/ -f2)"
  53. id="$(echo $result|cut -d\/ -f3|cut -d\| -f1)"
  54. title="$(echo $result|cut -d\| -f2)"
  55.  
  56. echo "Loading $type $title with id of $id"
  57.  
  58. if [[ "$type" == "tv" ]]
  59. then
  60.   url="${vid_url}$(get_episode)"
  61.   echo "$url"
  62.   open "$url"
  63. else
  64.   echo "${vid_url}movie?id=${id}"
  65.   xdg-open "${vid_url}movie?id=${id}"
  66. fi
  67.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement