torrents 1.0.10 → 1.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/torrents/container.rb +2 -2
- data/spec/trackers/the_pirate_bay_spec.rb +1 -1
- data/torrents.gemspec +1 -1
- metadata +1 -1
data/lib/torrents/container.rb
CHANGED
|
@@ -15,14 +15,14 @@ module Container
|
|
|
15
15
|
include Trackers
|
|
16
16
|
# Downloads the URL, returns an empty string if an error occurred
|
|
17
17
|
# Here we try to convert the downloaded content to UTF8,
|
|
18
|
-
# if we're at least
|
|
18
|
+
# if we're at least 60% sure that the content that was downloaded actally is was we think.
|
|
19
19
|
# The timeout is set to 10 seconds, after that time, an empty string will be returned.
|
|
20
20
|
# {url} (String) The URL to download
|
|
21
21
|
def download(url)
|
|
22
22
|
begin
|
|
23
23
|
data = RestClient.get self.url_cleaner(url), {:timeout => 10, :cookies => @cookies}
|
|
24
24
|
cd = CharDet.detect(data, silent: true)
|
|
25
|
-
raise Exception.new("The confidence level for #{url} is to low: #{cd.confidence}") if not cd.encoding.to_s.match(/^UTF(-)?8$/) and cd.confidence < 0.
|
|
25
|
+
raise Exception.new("The confidence level for #{url} is to low: #{cd.confidence}") if not cd.encoding.to_s.match(/^UTF(-)?8$/) and cd.confidence < 0.6
|
|
26
26
|
return Iconv.conv(cd.encoding + "//IGNORE", "UTF-8", data) rescue data
|
|
27
27
|
rescue Exception => error
|
|
28
28
|
self.error("Something when wrong when trying to fetch #{url}", error)
|
|
@@ -42,7 +42,7 @@ describe Trackers::ThePirateBay do
|
|
|
42
42
|
end
|
|
43
43
|
|
|
44
44
|
it "should return the right details link when trying to fetch recent torrents" do
|
|
45
|
-
rest_client("http://
|
|
45
|
+
rest_client("http://thepiratebay.org/torrent/6173093/", "recent")
|
|
46
46
|
Torrents.the_pirate_bay.results.each do |torrent|
|
|
47
47
|
torrent.details.should match(/http:\/\/thepiratebay\.org\/torrent\/\d+/)
|
|
48
48
|
end
|
data/torrents.gemspec
CHANGED