Advertisement
westor

TVMaze Search for isi1dur v1.1

Dec 19th, 2019
1,008
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. alias -l urlencode { return $regsubex($1-,/([^a-z0-9])/ig,% $+ $base($asc(\t),10,16,2)) }
  2.  
  3. alias tvmaze {
  4.  
  5.   var %u = https://api.tvmaze.com/singlesearch/shows?q= $+ $urlencode($1-)
  6.  
  7.   var %v = TVMAZE_ $+ $rand(1,1000000000)
  8.  
  9.   JSONOpen -ud %v %u
  10.  
  11.   if ($jsonerror) { echo 4 -gate No results founded. - Error Details: $jsonerror | return }
  12.  
  13.   var %id = $json(%v,id).value
  14.  
  15.   if (!%id) { echo 4 -gate No results founded. | return }
  16.  
  17.   var %name = $json(%v,name).value
  18.   var %type = $json(%v,type).value
  19.   var %language = $json(%v,language).value
  20.  
  21.   var %total_genres = $json(%v,genres).length
  22.   if (%total_genres) { var %i = 0 | while (%i <= %total_genres) { var %genres = $addtok(%genres,$json(%v,genres,%i).value,44) | inc %i } }
  23.  
  24.   var %network_name = $json(%v,network,name).value
  25.   var %network_couuntry_code = $json(%v,network,country,code).value
  26.   var %self_link = $json(%v,_links,self,href).value
  27.   var %self_previous_episode = $json(%v,_links,previousepisode,href).value
  28.  
  29.   if (%self_previous_episode) {
  30.     var %vv = TVMAZE2_ $+ $rand(1,100000000)
  31.  
  32.     JSONOpen -ud %vv %self_previous_episode
  33.  
  34.     if (!$jsonerror) { var %number = $json(%vv,number).value | var %season = $json(%vv,season).value }
  35.   }
  36.  
  37.   echo 3 -gate Name: $iif(%name,$v1,N/A) - Type: $iif(%type,$v1,N/A) - Language: $iif(%language,$v1,N/A) - Genres: $iif(%genres,$v1,N/A) - Network Name: $iif(%network_name,$v1,N/A) - Network Country Code: $iif(%network_couuntry_code,$v1,N/A) - Link: $iif(%self_link,$v1,N/A) - Previous Episode: $iif(%self_previous_episode,$v1,N/A) $iif(%number,Number: $v1) $iif(%season,Season: $v1)
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement