the_torrent_searcher 0.0.2
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.
- checksums.yaml +7 -0
- data/Gemfile +3 -0
- data/README.md +0 -0
- data/Rakefile +10 -0
- data/lib/the_torrent_searcher/torrent.rb +5 -0
- data/lib/the_torrent_searcher/torrent_searcher.rb +36 -0
- data/lib/the_torrent_searcher/torrentz_suggestions_page.rb +37 -0
- data/lib/the_torrent_searcher/version.rb +3 -0
- data/lib/the_torrent_searcher/workflow.rb +7 -0
- metadata +81 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 862e2bf415a20bd34e05d94b9bc70ff417dbfaff
|
|
4
|
+
data.tar.gz: df0cc7230a2f8d85fd4ff88dcaa6dcf3d2e7addb
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 93d93e52643973acf55be5288ef6965f949a970972a89f5b87c6281c75ad6f54d9dd00bd1a11ca98665de6e95ee6ad38d713c281023144ba7279602c1060d864
|
|
7
|
+
data.tar.gz: 03142ffb68740143153e9b4ab2852d5ac0dcf017e4b105caa74c8af2656777a9321af39e7f6c322d6e2ed0aaeb2d0196906ff9cf8b3d4a1033a340b27f1f0429
|
data/Gemfile
ADDED
data/README.md
ADDED
|
File without changes
|
data/Rakefile
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
$LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
|
|
2
|
+
require "the_torrent_searcher/version"
|
|
3
|
+
|
|
4
|
+
task :build do
|
|
5
|
+
system "gem build the_torrent_searcher.gemspec"
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
task :release => :build do
|
|
9
|
+
system "gem push the_torrent_searcher-#{TheTorrentSearcher::VERSION}.gem"
|
|
10
|
+
end
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
require 'mechanize'
|
|
2
|
+
require_relative './torrentz_suggestions_page'
|
|
3
|
+
|
|
4
|
+
module TheTorrentSearcher
|
|
5
|
+
class TorrentzSource
|
|
6
|
+
# contract: url
|
|
7
|
+
URLS = {
|
|
8
|
+
search: ->(keyword){ "http://torrentz.eu/search?f=#{keyword}" }
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
def url(key, *arguments)
|
|
12
|
+
URLS[key].call(*arguments)
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
class TorrentSearcher
|
|
17
|
+
attr_accessor :robot, :torrent_source
|
|
18
|
+
|
|
19
|
+
def suggestions_for(keyword)
|
|
20
|
+
page = robot.get(torrent_source.url(:search, keyword))
|
|
21
|
+
suggestions_page.get_suggestions(page)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def robot
|
|
25
|
+
@robot ||= Mechanize.new
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def torrent_source
|
|
29
|
+
@torrent_source ||= TorrentzSource.new
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def suggestions_page
|
|
33
|
+
@suggestions_page ||= TorrentzSuggestionsPage.new
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
require_relative './torrent'
|
|
2
|
+
|
|
3
|
+
module TheTorrentSearcher
|
|
4
|
+
class TorrentzSuggestionsPage
|
|
5
|
+
# contract: get_suggestions(page: mechanize_page)
|
|
6
|
+
|
|
7
|
+
def get_suggestions(page)
|
|
8
|
+
suggestion_elements(page).map do |suggestion|
|
|
9
|
+
build_torrent_suggestion(suggestion)
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
private
|
|
14
|
+
|
|
15
|
+
def build_torrent_suggestion(suggestion)
|
|
16
|
+
link_element = suggestion.search('dt a')
|
|
17
|
+
details_element = suggestion.search('dd')
|
|
18
|
+
|
|
19
|
+
return if details_element.search('.a').empty?
|
|
20
|
+
|
|
21
|
+
created_at = details_element.search('.a span').attr('title').value
|
|
22
|
+
|
|
23
|
+
Torrent.new.tap do |torrent|
|
|
24
|
+
torrent.link = link_element.attr('href').value
|
|
25
|
+
torrent.title = link_element.text
|
|
26
|
+
torrent.created_at = DateTime.parse(created_at)
|
|
27
|
+
torrent.size = details_element.search('.s').text
|
|
28
|
+
torrent.seeders = details_element.search('.u').text.gsub(',', '').to_i
|
|
29
|
+
torrent.leechers = details_element.search('.d').text.gsub(',', '').to_i
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def suggestion_elements(page)
|
|
34
|
+
page.search('.results dl')
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: the_torrent_searcher
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.2
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Julio García
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2014-01-19 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: mechanize
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - ">="
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '0'
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - ">="
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '0'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: rspec
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - ">="
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '0'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - ">="
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '0'
|
|
41
|
+
description: I love puppies. I love Alfred. So now you can search for suggestions
|
|
42
|
+
from Torrentz.eu within Alfred.
|
|
43
|
+
email:
|
|
44
|
+
- julioggonz@gmail.com
|
|
45
|
+
executables: []
|
|
46
|
+
extensions: []
|
|
47
|
+
extra_rdoc_files: []
|
|
48
|
+
files:
|
|
49
|
+
- Gemfile
|
|
50
|
+
- README.md
|
|
51
|
+
- Rakefile
|
|
52
|
+
- lib/the_torrent_searcher/torrent.rb
|
|
53
|
+
- lib/the_torrent_searcher/torrent_searcher.rb
|
|
54
|
+
- lib/the_torrent_searcher/torrentz_suggestions_page.rb
|
|
55
|
+
- lib/the_torrent_searcher/version.rb
|
|
56
|
+
- lib/the_torrent_searcher/workflow.rb
|
|
57
|
+
homepage: http://github.com/juliogarciag/the_torrent_searcher
|
|
58
|
+
licenses: []
|
|
59
|
+
metadata: {}
|
|
60
|
+
post_install_message:
|
|
61
|
+
rdoc_options: []
|
|
62
|
+
require_paths:
|
|
63
|
+
- lib
|
|
64
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - ">="
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '0'
|
|
69
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
70
|
+
requirements:
|
|
71
|
+
- - ">="
|
|
72
|
+
- !ruby/object:Gem::Version
|
|
73
|
+
version: '0'
|
|
74
|
+
requirements: []
|
|
75
|
+
rubyforge_project:
|
|
76
|
+
rubygems_version: 2.2.0
|
|
77
|
+
signing_key:
|
|
78
|
+
specification_version: 4
|
|
79
|
+
summary: A Torrenz.eu scrapper for personal use
|
|
80
|
+
test_files: []
|
|
81
|
+
has_rdoc:
|