lib/download_tv/grabbers/torrentapi.rb in download_tv-2.2.2 vs lib/download_tv/grabbers/torrentapi.rb in download_tv-2.3.0
- old
+ new
@@ -9,10 +9,20 @@
super('https://torrentapi.org/pubapi_v2.php?mode=search&search_string=%s&token=%s&app_id=DownloadTV')
@wait = 2.1
end
##
+ # Specific implementation for TorrentAPI (requires token)
+ def online?
+ @agent.read_timeout = 2
+ @agent.get(format(@url, 'test', 'test'))
+ true
+ rescue Mechanize::ResponseCodeError, Net::HTTP::Persistent::Error
+ false
+ end
+
+ ##
# Connects to Torrentapi.org and requests a token.
# Returns said token.
def renew_token
page = @agent.get('https://torrentapi.org/pubapi_v2.php?get_token=get_token&app_id=DownloadTV').content
@@ -52,11 +62,8 @@
names = obj['torrent_results'].collect { |i| i['filename'] }
links = obj['torrent_results'].collect { |i| i['download'] }
names.zip(links)
- # Temporary solution for Cloudflare being obnoxious
- rescue Mechanize::ResponseCodeError
- raise NoTorrentsError
end
end
end