Shadow19

The YouTube command for commands filter in DPE

Sep 1st, 2016
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 3.21 KB | None | 0 0
  1. Thread.new(decoy, args, argu) do |decoy, args, argu|
  2.     if args[0]
  3.         if !defined?(xeat)
  4.             def xeat(u)
  5.                 return eat(u)
  6.             end
  7.         end
  8.         decoy["<"].print(
  9.             packet(
  10.                 {
  11.                     "m"=>{
  12.                         "t"=>"Processing the YouTube query &quot;#{argu}&quot;",
  13.                         "u"=>"0",
  14.                         "i"=>"0"
  15.                     }
  16.                 }
  17.             )
  18.         )
  19.         query = "https://www.youtube.com/results?q=#{argu.downcase.strip.gsub(/\s+/,"+")}&sp=EgIQAQ%3D%3D"
  20.         if Thread.main["cache"]
  21.             tmp = query
  22.             tmp = Thread.main["cache"]["ytc#{csum(tmp)}"] if Thread.main["cache"]["ytc#{csum(tmp)}"]
  23.             tmp = false if !Thread.main["cache"]["ytc#{csum(tmp)}"]
  24.         end
  25.         if !tmp
  26.             error = false
  27.             search = xeat(query) rescue (error = true)
  28.             if !error
  29.                 vinfo = {}
  30.                 vinfo_a =
  31.                     [
  32.                         search.scan(/a href="\/watch\?v=(.*?)"/).collect{|i|i.join},
  33.                         search.scan(/a href="\/watch\?v=.*?\> - Duration: (.*?)\.\</).collect{|i|i.join},
  34.                        search.scan(/a href="\/watch\?v=.*?dir="ltr"\>(.*?)\</).collect{|i|i.join},
  35.                         search.scan(/a href="\/watch\?v=.*?ytid.*?\>(.*?)\</).collect{|i|i.join},
  36.                        search.scan(/a href="\/watch\?v=.*?\/li\>\<li\>(.*?)\s*views\</).collect{|i|i.join},
  37.                         search.scan(/a href="\/watch\?v=.*?li\>(.*?)\</).collect{|i|i.join}
  38.                    ]
  39.                vinfo_a[0].each_with_index do |video, index|
  40.                    vinfo[video] =
  41.                    {
  42.                        "time"=>vinfo_a[1][index],
  43.                        "title"=>vinfo_a[2][index],
  44.                        "user"=>vinfo_a[3][index],
  45.                        "views"=>vinfo_a[4][index].sub("No","0"),
  46.                        "created"=>vinfo_a[5][index]
  47.                    }
  48.                end
  49.                Thread.main["cache"]["ytc#{csum(query)}"] = vinfo if Thread.main["cache"]
  50.             else
  51.                 decoy["<"].print(
  52.                     packet(
  53.                         {
  54.                             "m"=>{
  55.                                 "t"=>"The YouTube query &quot;#{argu}&quot; failed..",
  56.                                 "u"=>"0",
  57.                                 "i"=>"0"
  58.                             }
  59.                         }
  60.                     )
  61.                 )
  62.                 Thread.current.kill
  63.             end
  64.         else
  65.             vinfo = tmp
  66.         end
  67.         vinfo.keys[0..3].each do |video|
  68.             info = vinfo[video]
  69.             decoy["<"].print(
  70.                 packet(
  71.                     {
  72.                         "m"=>{
  73.                             "t"=>"https://youtube.com/v/#{video} - #{info["title"]} - #{info["time"]} - Viewed #{info["views"]} times and created by #{info["user"]} #{info["created"]}.",
  74.                             "u"=>"0",
  75.                             "i"=>"0"
  76.                         }
  77.                     }
  78.                 )
  79.             )
  80.         end
  81.     end
  82. end
Advertisement
Add Comment
Please, Sign In to add comment