Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Thread.new(decoy, args, argu) do |decoy, args, argu|
- if args[0]
- if !defined?(xeat)
- def xeat(u)
- return eat(u)
- end
- end
- decoy["<"].print(
- packet(
- {
- "m"=>{
- "t"=>"Processing the YouTube query "#{argu}"",
- "u"=>"0",
- "i"=>"0"
- }
- }
- )
- )
- query = "https://www.youtube.com/results?q=#{argu.downcase.strip.gsub(/\s+/,"+")}&sp=EgIQAQ%3D%3D"
- if Thread.main["cache"]
- tmp = query
- tmp = Thread.main["cache"]["ytc#{csum(tmp)}"] if Thread.main["cache"]["ytc#{csum(tmp)}"]
- tmp = false if !Thread.main["cache"]["ytc#{csum(tmp)}"]
- end
- if !tmp
- error = false
- search = xeat(query) rescue (error = true)
- if !error
- vinfo = {}
- vinfo_a =
- [
- search.scan(/a href="\/watch\?v=(.*?)"/).collect{|i|i.join},
- search.scan(/a href="\/watch\?v=.*?\> - Duration: (.*?)\.\</).collect{|i|i.join},
- search.scan(/a href="\/watch\?v=.*?dir="ltr"\>(.*?)\</).collect{|i|i.join},
- search.scan(/a href="\/watch\?v=.*?ytid.*?\>(.*?)\</).collect{|i|i.join},
- search.scan(/a href="\/watch\?v=.*?\/li\>\<li\>(.*?)\s*views\</).collect{|i|i.join},
- search.scan(/a href="\/watch\?v=.*?li\>(.*?)\</).collect{|i|i.join}
- ]
- vinfo_a[0].each_with_index do |video, index|
- vinfo[video] =
- {
- "time"=>vinfo_a[1][index],
- "title"=>vinfo_a[2][index],
- "user"=>vinfo_a[3][index],
- "views"=>vinfo_a[4][index].sub("No","0"),
- "created"=>vinfo_a[5][index]
- }
- end
- Thread.main["cache"]["ytc#{csum(query)}"] = vinfo if Thread.main["cache"]
- else
- decoy["<"].print(
- packet(
- {
- "m"=>{
- "t"=>"The YouTube query "#{argu}" failed..",
- "u"=>"0",
- "i"=>"0"
- }
- }
- )
- )
- Thread.current.kill
- end
- else
- vinfo = tmp
- end
- vinfo.keys[0..3].each do |video|
- info = vinfo[video]
- decoy["<"].print(
- packet(
- {
- "m"=>{
- "t"=>"https://youtube.com/v/#{video} - #{info["title"]} - #{info["time"]} - Viewed #{info["views"]} times and created by #{info["user"]} #{info["created"]}.",
- "u"=>"0",
- "i"=>"0"
- }
- }
- )
- )
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment