Advertisement
Guest User

Untitled

a guest
Jan 16th, 2017
248
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.79 KB | None | 0 0
  1. on *:text:*:#canal: {
  2. if (!%YOUTUBE-PARSERversion) || (!%YOUTUBE-PARSERversion != v0.1) { set %YOUTUBE-PARSERversion v0.1 }
  3. tokenize 32 $strip($1-,burci)
  4. if (youtube.com isin $1-) { var %yt_t $gettok($1-,2,61) | set %yt_c # | _youtube %yt_t }
  5. if (youtu.be isin $1-) { var %yt_t $gettok($1-,3,47) | set %yt_c # | _youtube %yt_t }
  6. }
  7.  
  8. on *:action:*:#: {
  9. tokenize 32 $strip($1-,burci)
  10. if (youtube.com isin $1-) { var %yt_t $gettok($1-,2,61) | set %yt_c # | _youtube %yt_t }
  11. if (youtu.be isin $1-) { var %yt_t $gettok($1-,3,47) | set %yt_c # | _youtube %yt_t }
  12. }
  13.  
  14. alias _YouTube {
  15. sockclose $+(Ytb,.,$1)
  16. sockopen -e $+(Ytb,.,$1) www.googleapis.com 443
  17. }
  18. on *:sockopen:*: {
  19. if (Ytb* iswm $sockname) {
  20. if ($sockerr) { sockclose $sockname | halt }
  21. sockwrite -nt $sockname GET /youtube/v3/videos?id= $+ $remove($sockname,Ytb.) $+ &key=AIzaSyCzHxG53pxE0hWrWBIMMGm75PRHBQ8ZP8c&part=snippet,contentDetails,statistics,topicDetails HTTP/1.1
  22. sockwrite -nt $sockname Host: www.googleapis.com
  23. sockwrite -nt $sockname $crlf
  24. }
  25. }
  26. on *:sockread:*: {
  27. if (Ytb* iswm $sockname) {
  28. if ($sockerr) { return }
  29. var %read
  30. sockread -f %read
  31. while ($sockbr) {
  32. if (%read) {
  33. if ("title" isin $gettok(%read,1,32)) { set %yt_title $left($noqt($gettok(%read,2-,32)),-2) }
  34. if ("categoryId" isin $gettok(%read,1,32)) {
  35. var %a = $left($noqt($gettok(%read,2-,32)),-2)
  36. set %yt_category $replace(%a,1,Film & Animation,02,Autos & Vehicles,10,Music,15,Pets & Animals,17,Sports,18,Short Movies,19,Travel & Events,20,Gaming,21,Videoblogging,22,People & Blogs,23,Comedy,24,Entertainment,25,News & Politics,26,Howto & Style,27,Education,28,Science & Technology,29,Nonprofits & Activism,30,Movies,31,Anime/Animation,32,Action/Adventure,33,Classics,34,Comedy,35,Documentary,36,Drama,37,Family,38,Foreign,39,Horror,40,Sci-Fi/Fantasy,41,Thriller,42,Shorts,43,Shows,44,Trailers)
  37. }
  38. if ("viewCount" isin $gettok(%read,1,32)) { set %yt_views $left($noqt($gettok(%read,2-,32)),-2) }
  39. if ("likeCount" isin $gettok(%read,1,32)) { set %yt_likes $left($noqt($gettok(%read,2-,32)),-2) }
  40. if ("dislikeCount" isin $gettok(%read,1,32)) { set %yt_dislikes $left($noqt($gettok(%read,2-,32)),-2) }
  41. if ("channelTitle" isin $gettok(%read,1,32)) { set %yt_uploaded $left($noqt($gettok(%read,2-,32)),-2) }
  42. if ("duration" isin $gettok(%read,1,32)) { set %yt_duration $get_duration($left($noqt($gettok(%read,2-,32)),-1)) }
  43. if ("commentCount" isin $gettok(%read,1,32)) {
  44. set %yt_comments $noqt($gettok(%read,2-,32))
  45. sockclose $sockname
  46. msg %yt_c 1,0You00,04Tube: 1Titulo14:1 %yt_title  1Duracion1:12 %yt_duration
  47. unset %yt_*
  48. return
  49. }
  50. }
  51. sockread -f %read
  52. }
  53. }
  54. }
  55. alias get_duration {
  56. if (!$1) { return 0 }
  57. var %d = $1
  58. var %d = $remove(%d,P,T)
  59. var %d = $replacex(%d,W,wk $chr(32),D,days $chr(32),h,hrs $chr(32),M,mins $chr(32),S,secs)
  60. var %d = $duration(%d,3)
  61. var %dd = $duration(%d,3)
  62. return $iif(%dd,$v1,00:00:00)
  63. }
  64.  
  65. alias get_date {
  66. if (!$1-) { return 0 }
  67. var %d = $1-
  68. var %d = $remove($replace(%d,$chr(84),$chr(32)),$chr(90))
  69. if (*.* iswm %d) {
  70. var %tmp_d = $gettok(%d,1,32)
  71. var %tmp_t = $remove($gettok(%d,2,32),.)
  72. var %d = %tmp_d $gettok(%tmp_t,1,58) $+ : $+ $gettok(%tmp_t,2,58) $+ : $+ $mid($gettok(%tmp_t,3,58),4)
  73. }
  74. var %d = $ctime($remove(%d,$chr(44)))
  75. var %d = $date(%d,ddd ddoo mmm yyyy HH:nn:ss)
  76. if (!$prop) { return %d }
  77. if ($prop) && ($prop == date) { return $iif(%d,$v1,0) }
  78. if ($prop) && ($prop == ctime) { return $iif($ctime(%d),$v1,0) }
  79. }
  80.  
  81. alias -l comma {
  82. var %a, %b = $regsub($ticks,$1,/\G([+-]?\d+?)(?=(?:\d{3})++(?=\.\d++$|$))/g,\1 $+ $chr(44),%a)
  83. return %a
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement