class RMD::Zing::Song
Public Instance Methods
fetch()
click to toggle source
# File lib/rmd/zing/song.rb, line 8 def fetch if new_link @data_link = RMD::Zing::Utils::CorrectUrl.correct(new_link) else @errors = 'Can not get song from this link!' end end
Private Instance Methods
agent()
click to toggle source
# File lib/rmd/zing/song.rb, line 18 def agent @agent ||= Mechanize.new end
new_link()
click to toggle source
# File lib/rmd/zing/song.rb, line 30 def new_link @new_link ||= uncached_new_link end
page()
click to toggle source
# File lib/rmd/zing/song.rb, line 22 def page @page ||= agent.get(link) end
regex()
click to toggle source
# File lib/rmd/zing/song.rb, line 26 def regex /http\:\/\/mp3.zing.vn\/download\/song\/\S+\/\w+/ end
uncached_new_link()
click to toggle source
# File lib/rmd/zing/song.rb, line 34 def uncached_new_link page.search('.detail-function script').each do |element| if match_data = regex.match(element.text) return match_data.to_s end end nil end