piratebay_api 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/.idea/misc.xml +14 -0
- data/.idea/modules.xml +8 -0
- data/.idea/piratebay_api.iml +25 -0
- data/.idea/vcs.xml +6 -0
- data/.idea/workspace.xml +441 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +31 -0
- data/Rakefile +2 -0
- data/lib/piratebay_api/categories.rb +49 -0
- data/lib/piratebay_api/details.rb +111 -0
- data/lib/piratebay_api/pirate_bay.rb +105 -0
- data/lib/piratebay_api/result.rb +62 -0
- data/lib/piratebay_api/result_set.rb +18 -0
- data/lib/piratebay_api/version.rb +3 -0
- data/lib/piratebay_api.rb +44 -0
- data/piratebay_api.gemspec +27 -0
- metadata +132 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e9b44d865bb9306f643afd7475d4da5881bbec48
|
4
|
+
data.tar.gz: b6393a56155ff3cd82d2dc3a33fd6e7005689268
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: bc9c02def67d8a27112fc2e6e417f08e6033226c00107d8cd9a26ba81285733b19a0cf948f81231bf7106dca99774e125faa7897d41176093ff5ddf35d0a7b83
|
7
|
+
data.tar.gz: 8bf4cac9f452a421f6d9e6162c7301b4f66e5d747523daabc282a2551d57fbcad81576467cc70b9c33f981a3a81174fc37e5f5c104ff1dcaeb97f97185441ce9
|
data/.gitignore
ADDED
data/.idea/misc.xml
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<project version="4">
|
3
|
+
<component name="ProjectLevelVcsManager" settingsEditedManually="false">
|
4
|
+
<OptionsSetting value="true" id="Add" />
|
5
|
+
<OptionsSetting value="true" id="Remove" />
|
6
|
+
<OptionsSetting value="true" id="Checkout" />
|
7
|
+
<OptionsSetting value="true" id="Update" />
|
8
|
+
<OptionsSetting value="true" id="Status" />
|
9
|
+
<OptionsSetting value="true" id="Edit" />
|
10
|
+
<ConfirmationsSetting value="0" id="Add" />
|
11
|
+
<ConfirmationsSetting value="0" id="Remove" />
|
12
|
+
</component>
|
13
|
+
<component name="ProjectRootManager" version="2" project-jdk-name="ruby-2.1.5-p273" project-jdk-type="RUBY_SDK" />
|
14
|
+
</project>
|
data/.idea/modules.xml
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<project version="4">
|
3
|
+
<component name="ProjectModuleManager">
|
4
|
+
<modules>
|
5
|
+
<module fileurl="file://$PROJECT_DIR$/.idea/piratebay_api.iml" filepath="$PROJECT_DIR$/.idea/piratebay_api.iml" />
|
6
|
+
</modules>
|
7
|
+
</component>
|
8
|
+
</project>
|
@@ -0,0 +1,25 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<module type="RUBY_MODULE" version="4">
|
3
|
+
<component name="FacetManager">
|
4
|
+
<facet type="gem" name="Ruby Gem">
|
5
|
+
<configuration>
|
6
|
+
<option name="GEM_APP_ROOT_PATH" value="$MODULE_DIR$" />
|
7
|
+
<option name="GEM_APP_TEST_PATH" value="$MODULE_DIR$/test" />
|
8
|
+
<option name="GEM_APP_LIB_PATH" value="$MODULE_DIR$/lib" />
|
9
|
+
</configuration>
|
10
|
+
</facet>
|
11
|
+
</component>
|
12
|
+
<component name="NewModuleRootManager">
|
13
|
+
<content url="file://$MODULE_DIR$">
|
14
|
+
<sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />
|
15
|
+
</content>
|
16
|
+
<orderEntry type="inheritedJdk" />
|
17
|
+
<orderEntry type="sourceFolder" forTests="false" />
|
18
|
+
<orderEntry type="library" scope="PROVIDED" name="awesome_print (v0.4.0, ruby-2.1.5-p273) [gem]" level="application" />
|
19
|
+
<orderEntry type="library" scope="PROVIDED" name="bundler (v1.7.7, ruby-2.1.5-p273) [gem]" level="application" />
|
20
|
+
<orderEntry type="library" scope="PROVIDED" name="hpricot (v0.8.6, ruby-2.1.5-p273) [gem]" level="application" />
|
21
|
+
<orderEntry type="library" scope="PROVIDED" name="mini_portile (v0.6.2, ruby-2.1.5-p273) [gem]" level="application" />
|
22
|
+
<orderEntry type="library" scope="PROVIDED" name="nokogiri (v1.6.6.2, ruby-2.1.5-p273) [gem]" level="application" />
|
23
|
+
<orderEntry type="library" scope="PROVIDED" name="rake (v10.4.2, ruby-2.1.5-p273) [gem]" level="application" />
|
24
|
+
</component>
|
25
|
+
</module>
|
data/.idea/vcs.xml
ADDED
data/.idea/workspace.xml
ADDED
@@ -0,0 +1,441 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<project version="4">
|
3
|
+
<component name="ChangeListManager">
|
4
|
+
<list default="true" id="da40877e-0aec-4a2e-867f-ad9195b4be60" name="Default" comment="" />
|
5
|
+
<ignored path="piratebay_api.iws" />
|
6
|
+
<ignored path=".idea/workspace.xml" />
|
7
|
+
<ignored path=".idea/dataSources.local.xml" />
|
8
|
+
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
|
9
|
+
<option name="TRACKING_ENABLED" value="true" />
|
10
|
+
<option name="SHOW_DIALOG" value="false" />
|
11
|
+
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
12
|
+
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
13
|
+
<option name="LAST_RESOLUTION" value="IGNORE" />
|
14
|
+
</component>
|
15
|
+
<component name="ChangesViewManager" flattened_view="true" show_ignored="false" />
|
16
|
+
<component name="CreatePatchCommitExecutor">
|
17
|
+
<option name="PATCH_PATH" value="" />
|
18
|
+
</component>
|
19
|
+
<component name="ExecutionTargetManager" SELECTED_TARGET="default_target" />
|
20
|
+
<component name="FavoritesManager">
|
21
|
+
<favorites_list name="piratebay_api" />
|
22
|
+
</component>
|
23
|
+
<component name="FileEditorManager">
|
24
|
+
<leaf>
|
25
|
+
<file leaf-file-name="piratebay_api.rb" pinned="false" current-in-tab="false">
|
26
|
+
<entry file="file://$PROJECT_DIR$/lib/piratebay_api.rb">
|
27
|
+
<provider selected="true" editor-type-id="text-editor">
|
28
|
+
<state vertical-scroll-proportion="0.0">
|
29
|
+
<caret line="26" column="12" selection-start-line="26" selection-start-column="12" selection-end-line="26" selection-end-column="12" />
|
30
|
+
<folding />
|
31
|
+
</state>
|
32
|
+
</provider>
|
33
|
+
</entry>
|
34
|
+
</file>
|
35
|
+
<file leaf-file-name="categories.rb" pinned="false" current-in-tab="false">
|
36
|
+
<entry file="file://$PROJECT_DIR$/lib/piratebay_api/categories.rb">
|
37
|
+
<provider selected="true" editor-type-id="text-editor">
|
38
|
+
<state vertical-scroll-proportion="0.0">
|
39
|
+
<caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
|
40
|
+
<folding />
|
41
|
+
</state>
|
42
|
+
</provider>
|
43
|
+
</entry>
|
44
|
+
</file>
|
45
|
+
<file leaf-file-name="details.rb" pinned="false" current-in-tab="false">
|
46
|
+
<entry file="file://$PROJECT_DIR$/lib/piratebay_api/details.rb">
|
47
|
+
<provider selected="true" editor-type-id="text-editor">
|
48
|
+
<state vertical-scroll-proportion="0.0">
|
49
|
+
<caret line="16" column="2" selection-start-line="16" selection-start-column="2" selection-end-line="16" selection-end-column="2" />
|
50
|
+
<folding />
|
51
|
+
</state>
|
52
|
+
</provider>
|
53
|
+
</entry>
|
54
|
+
</file>
|
55
|
+
<file leaf-file-name="pirate_bay.rb" pinned="false" current-in-tab="true">
|
56
|
+
<entry file="file://$PROJECT_DIR$/lib/piratebay_api/pirate_bay.rb">
|
57
|
+
<provider selected="true" editor-type-id="text-editor">
|
58
|
+
<state vertical-scroll-proportion="0.50163937">
|
59
|
+
<caret line="29" column="20" selection-start-line="29" selection-start-column="20" selection-end-line="29" selection-end-column="20" />
|
60
|
+
<folding />
|
61
|
+
</state>
|
62
|
+
</provider>
|
63
|
+
</entry>
|
64
|
+
</file>
|
65
|
+
<file leaf-file-name="result.rb" pinned="false" current-in-tab="false">
|
66
|
+
<entry file="file://$PROJECT_DIR$/lib/piratebay_api/result.rb">
|
67
|
+
<provider selected="true" editor-type-id="text-editor">
|
68
|
+
<state vertical-scroll-proportion="0.0">
|
69
|
+
<caret line="5" column="17" selection-start-line="5" selection-start-column="8" selection-end-line="5" selection-end-column="17" />
|
70
|
+
<folding />
|
71
|
+
</state>
|
72
|
+
</provider>
|
73
|
+
</entry>
|
74
|
+
</file>
|
75
|
+
<file leaf-file-name="result_set.rb" pinned="false" current-in-tab="false">
|
76
|
+
<entry file="file://$PROJECT_DIR$/lib/piratebay_api/result_set.rb">
|
77
|
+
<provider selected="true" editor-type-id="text-editor">
|
78
|
+
<state vertical-scroll-proportion="0.0">
|
79
|
+
<caret line="16" column="5" selection-start-line="16" selection-start-column="5" selection-end-line="16" selection-end-column="5" />
|
80
|
+
<folding />
|
81
|
+
</state>
|
82
|
+
</provider>
|
83
|
+
</entry>
|
84
|
+
</file>
|
85
|
+
<file leaf-file-name="version.rb" pinned="false" current-in-tab="false">
|
86
|
+
<entry file="file://$PROJECT_DIR$/lib/piratebay_api/version.rb">
|
87
|
+
<provider selected="true" editor-type-id="text-editor">
|
88
|
+
<state vertical-scroll-proportion="0.0">
|
89
|
+
<caret line="3" column="0" selection-start-line="3" selection-start-column="0" selection-end-line="3" selection-end-column="0" />
|
90
|
+
<folding />
|
91
|
+
</state>
|
92
|
+
</provider>
|
93
|
+
</entry>
|
94
|
+
</file>
|
95
|
+
<file leaf-file-name="piratebay_api.gemspec" pinned="false" current-in-tab="false">
|
96
|
+
<entry file="file://$PROJECT_DIR$/piratebay_api.gemspec">
|
97
|
+
<provider selected="true" editor-type-id="text-editor">
|
98
|
+
<state vertical-scroll-proportion="0.0">
|
99
|
+
<caret line="8" column="31" selection-start-line="8" selection-start-column="31" selection-end-line="8" selection-end-column="31" />
|
100
|
+
<folding />
|
101
|
+
</state>
|
102
|
+
</provider>
|
103
|
+
</entry>
|
104
|
+
</file>
|
105
|
+
</leaf>
|
106
|
+
</component>
|
107
|
+
<component name="Git.Settings">
|
108
|
+
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
|
109
|
+
</component>
|
110
|
+
<component name="IdeDocumentHistory">
|
111
|
+
<option name="CHANGED_PATHS">
|
112
|
+
<list>
|
113
|
+
<option value="$PROJECT_DIR$/piratebay_api.gemspec" />
|
114
|
+
<option value="$PROJECT_DIR$/lib/piratebay_api.rb" />
|
115
|
+
<option value="$PROJECT_DIR$/lib/piratebay_api/version.rb" />
|
116
|
+
<option value="$PROJECT_DIR$/lib/piratebay_api/result.rb" />
|
117
|
+
<option value="$PROJECT_DIR$/lib/piratebay_api/pirate_bay.rb" />
|
118
|
+
<option value="$PROJECT_DIR$/lib/piratebay_api/details.rb" />
|
119
|
+
</list>
|
120
|
+
</option>
|
121
|
+
</component>
|
122
|
+
<component name="JsBuildToolGruntFileManager" detection-done="true" />
|
123
|
+
<component name="JsGulpfileManager">
|
124
|
+
<detection-done>true</detection-done>
|
125
|
+
</component>
|
126
|
+
<component name="NamedScopeManager">
|
127
|
+
<order />
|
128
|
+
</component>
|
129
|
+
<component name="ProjectFrameBounds">
|
130
|
+
<option name="x" value="-8" />
|
131
|
+
<option name="y" value="-8" />
|
132
|
+
<option name="width" value="1936" />
|
133
|
+
<option name="height" value="1056" />
|
134
|
+
</component>
|
135
|
+
<component name="ProjectLevelVcsManager" settingsEditedManually="true">
|
136
|
+
<OptionsSetting value="true" id="Add" />
|
137
|
+
<OptionsSetting value="true" id="Remove" />
|
138
|
+
<OptionsSetting value="true" id="Checkout" />
|
139
|
+
<OptionsSetting value="true" id="Update" />
|
140
|
+
<OptionsSetting value="true" id="Status" />
|
141
|
+
<OptionsSetting value="true" id="Edit" />
|
142
|
+
<ConfirmationsSetting value="0" id="Add" />
|
143
|
+
<ConfirmationsSetting value="0" id="Remove" />
|
144
|
+
</component>
|
145
|
+
<component name="ProjectView">
|
146
|
+
<navigator currentView="ProjectPane" proportions="" version="1">
|
147
|
+
<flattenPackages />
|
148
|
+
<showMembers />
|
149
|
+
<showModules />
|
150
|
+
<showLibraryContents />
|
151
|
+
<hideEmptyPackages />
|
152
|
+
<abbreviatePackageNames />
|
153
|
+
<autoscrollToSource />
|
154
|
+
<autoscrollFromSource />
|
155
|
+
<sortByType />
|
156
|
+
</navigator>
|
157
|
+
<panes>
|
158
|
+
<pane id="Scratches" />
|
159
|
+
<pane id="Scope" />
|
160
|
+
<pane id="ProjectPane">
|
161
|
+
<subPane>
|
162
|
+
<PATH>
|
163
|
+
<PATH_ELEMENT>
|
164
|
+
<option name="myItemId" value="piratebay_api" />
|
165
|
+
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
|
166
|
+
</PATH_ELEMENT>
|
167
|
+
</PATH>
|
168
|
+
<PATH>
|
169
|
+
<PATH_ELEMENT>
|
170
|
+
<option name="myItemId" value="piratebay_api" />
|
171
|
+
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
|
172
|
+
</PATH_ELEMENT>
|
173
|
+
<PATH_ELEMENT>
|
174
|
+
<option name="myItemId" value="piratebay_api" />
|
175
|
+
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
|
176
|
+
</PATH_ELEMENT>
|
177
|
+
</PATH>
|
178
|
+
<PATH>
|
179
|
+
<PATH_ELEMENT>
|
180
|
+
<option name="myItemId" value="piratebay_api" />
|
181
|
+
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
|
182
|
+
</PATH_ELEMENT>
|
183
|
+
<PATH_ELEMENT>
|
184
|
+
<option name="myItemId" value="piratebay_api" />
|
185
|
+
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
|
186
|
+
</PATH_ELEMENT>
|
187
|
+
<PATH_ELEMENT>
|
188
|
+
<option name="myItemId" value="lib" />
|
189
|
+
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
|
190
|
+
</PATH_ELEMENT>
|
191
|
+
</PATH>
|
192
|
+
<PATH>
|
193
|
+
<PATH_ELEMENT>
|
194
|
+
<option name="myItemId" value="piratebay_api" />
|
195
|
+
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
|
196
|
+
</PATH_ELEMENT>
|
197
|
+
<PATH_ELEMENT>
|
198
|
+
<option name="myItemId" value="piratebay_api" />
|
199
|
+
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
|
200
|
+
</PATH_ELEMENT>
|
201
|
+
<PATH_ELEMENT>
|
202
|
+
<option name="myItemId" value="lib" />
|
203
|
+
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
|
204
|
+
</PATH_ELEMENT>
|
205
|
+
<PATH_ELEMENT>
|
206
|
+
<option name="myItemId" value="piratebay_api" />
|
207
|
+
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
|
208
|
+
</PATH_ELEMENT>
|
209
|
+
</PATH>
|
210
|
+
</subPane>
|
211
|
+
</pane>
|
212
|
+
</panes>
|
213
|
+
</component>
|
214
|
+
<component name="PropertiesComponent">
|
215
|
+
<property name="WebServerToolWindowFactoryState" value="false" />
|
216
|
+
<property name="last_opened_file_path" value="$PROJECT_DIR$" />
|
217
|
+
<property name="FullScreen" value="false" />
|
218
|
+
</component>
|
219
|
+
<component name="RunManager">
|
220
|
+
<configuration default="true" type="JavascriptDebugType" factoryName="JavaScript Debug">
|
221
|
+
<method />
|
222
|
+
</configuration>
|
223
|
+
<configuration default="true" type="RubyRunConfigurationType" factoryName="Ruby">
|
224
|
+
<module name="" />
|
225
|
+
<RUBY_RUN_CONFIG NAME="RUBY_ARGS" VALUE="-e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift)" />
|
226
|
+
<RUBY_RUN_CONFIG NAME="WORK DIR" VALUE="" />
|
227
|
+
<RUBY_RUN_CONFIG NAME="SHOULD_USE_SDK" VALUE="false" />
|
228
|
+
<RUBY_RUN_CONFIG NAME="ALTERN_SDK_NAME" VALUE="" />
|
229
|
+
<RUBY_RUN_CONFIG NAME="myPassParentEnvs" VALUE="true" />
|
230
|
+
<envs />
|
231
|
+
<EXTENSION ID="BundlerRunConfigurationExtension" bundleExecEnabled="false" />
|
232
|
+
<EXTENSION ID="JRubyRunConfigurationExtension" NailgunExecEnabled="false" />
|
233
|
+
<EXTENSION ID="RubyCoverageRunConfigurationExtension" enabled="false" sample_coverage="true" track_test_folders="true" runner="rcov" />
|
234
|
+
<EXTENSION ID="org.jetbrains.plugins.ruby.motion.run.MotionSimulatorRunExtension" />
|
235
|
+
<RUBY_RUN_CONFIG NAME="SCRIPT_PATH" VALUE="" />
|
236
|
+
<RUBY_RUN_CONFIG NAME="SCRIPT_ARGS" VALUE="" />
|
237
|
+
<method />
|
238
|
+
</configuration>
|
239
|
+
<configuration default="true" type="js.build_tools.gulp" factoryName="Gulp.js">
|
240
|
+
<node-options />
|
241
|
+
<gulpfile />
|
242
|
+
<tasks />
|
243
|
+
<arguments />
|
244
|
+
<pass-parent-envs>true</pass-parent-envs>
|
245
|
+
<envs />
|
246
|
+
<method />
|
247
|
+
</configuration>
|
248
|
+
</component>
|
249
|
+
<component name="ShelveChangesManager" show_recycled="false" />
|
250
|
+
<component name="SvnConfiguration">
|
251
|
+
<configuration />
|
252
|
+
</component>
|
253
|
+
<component name="TaskManager">
|
254
|
+
<task active="true" id="Default" summary="Default task">
|
255
|
+
<changelist id="da40877e-0aec-4a2e-867f-ad9195b4be60" name="Default" comment="" />
|
256
|
+
<created>1430693866410</created>
|
257
|
+
<option name="number" value="Default" />
|
258
|
+
<updated>1430693866410</updated>
|
259
|
+
</task>
|
260
|
+
<servers />
|
261
|
+
</component>
|
262
|
+
<component name="TodoView">
|
263
|
+
<todo-panel id="selected-file">
|
264
|
+
<is-autoscroll-to-source value="true" />
|
265
|
+
</todo-panel>
|
266
|
+
<todo-panel id="all">
|
267
|
+
<are-packages-shown value="true" />
|
268
|
+
<is-autoscroll-to-source value="true" />
|
269
|
+
</todo-panel>
|
270
|
+
</component>
|
271
|
+
<component name="ToolWindowManager">
|
272
|
+
<frame x="-8" y="-8" width="1936" height="1056" extended-state="6" />
|
273
|
+
<editor active="true" />
|
274
|
+
<layout>
|
275
|
+
<window_info id="Messages" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.32842106" sideWeight="0.4914712" order="7" side_tool="false" content_ui="tabs" />
|
276
|
+
<window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.3263158" sideWeight="0.4914712" order="7" side_tool="false" content_ui="tabs" />
|
277
|
+
<window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.32899022" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
|
278
|
+
<window_info id="Database" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
|
279
|
+
<window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
|
280
|
+
<window_info id="Application Servers" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
|
281
|
+
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.2553305" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" />
|
282
|
+
<window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.4" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
|
283
|
+
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.32842106" sideWeight="0.4936034" order="2" side_tool="false" content_ui="tabs" />
|
284
|
+
<window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="2" side_tool="true" content_ui="tabs" />
|
285
|
+
<window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.32842106" sideWeight="0.5063966" order="7" side_tool="true" content_ui="tabs" />
|
286
|
+
<window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
|
287
|
+
<window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
|
288
|
+
<window_info id="Message" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
|
289
|
+
<window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
|
290
|
+
<window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
|
291
|
+
<window_info id="Commander" active="false" anchor="right" auto_hide="false" internal_type="SLIDING" type="SLIDING" visible="false" weight="0.4" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
|
292
|
+
<window_info id="Inspection" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.4" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
|
293
|
+
<window_info id="Hierarchy" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="2" side_tool="false" content_ui="combo" />
|
294
|
+
</layout>
|
295
|
+
</component>
|
296
|
+
<component name="Vcs.Log.UiProperties">
|
297
|
+
<option name="RECENTLY_FILTERED_USER_GROUPS">
|
298
|
+
<collection />
|
299
|
+
</option>
|
300
|
+
<option name="RECENTLY_FILTERED_BRANCH_GROUPS">
|
301
|
+
<collection />
|
302
|
+
</option>
|
303
|
+
</component>
|
304
|
+
<component name="VcsContentAnnotationSettings">
|
305
|
+
<option name="myLimit" value="2678400000" />
|
306
|
+
</component>
|
307
|
+
<component name="XDebuggerManager">
|
308
|
+
<breakpoint-manager />
|
309
|
+
<watches-manager />
|
310
|
+
</component>
|
311
|
+
<component name="editorHistoryManager">
|
312
|
+
<entry file="file://$PROJECT_DIR$/lib/piratebay_api.rb">
|
313
|
+
<provider selected="true" editor-type-id="text-editor">
|
314
|
+
<state vertical-scroll-proportion="0.0">
|
315
|
+
<caret line="26" column="12" selection-start-line="26" selection-start-column="12" selection-end-line="26" selection-end-column="12" />
|
316
|
+
<folding />
|
317
|
+
</state>
|
318
|
+
</provider>
|
319
|
+
</entry>
|
320
|
+
<entry file="file://$PROJECT_DIR$/lib/piratebay_api/categories.rb">
|
321
|
+
<provider selected="true" editor-type-id="text-editor">
|
322
|
+
<state vertical-scroll-proportion="0.0">
|
323
|
+
<caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
|
324
|
+
<folding />
|
325
|
+
</state>
|
326
|
+
</provider>
|
327
|
+
</entry>
|
328
|
+
<entry file="file://$PROJECT_DIR$/lib/piratebay_api/details.rb">
|
329
|
+
<provider selected="true" editor-type-id="text-editor">
|
330
|
+
<state vertical-scroll-proportion="0.0">
|
331
|
+
<caret line="16" column="2" selection-start-line="16" selection-start-column="2" selection-end-line="16" selection-end-column="2" />
|
332
|
+
<folding />
|
333
|
+
</state>
|
334
|
+
</provider>
|
335
|
+
</entry>
|
336
|
+
<entry file="file://$PROJECT_DIR$/lib/piratebay_api/pirate_bay.rb">
|
337
|
+
<provider selected="true" editor-type-id="text-editor">
|
338
|
+
<state vertical-scroll-proportion="0.0">
|
339
|
+
<caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
|
340
|
+
<folding />
|
341
|
+
</state>
|
342
|
+
</provider>
|
343
|
+
</entry>
|
344
|
+
<entry file="file://$PROJECT_DIR$/lib/piratebay_api/result.rb">
|
345
|
+
<provider selected="true" editor-type-id="text-editor">
|
346
|
+
<state vertical-scroll-proportion="0.0">
|
347
|
+
<caret line="5" column="17" selection-start-line="5" selection-start-column="8" selection-end-line="5" selection-end-column="17" />
|
348
|
+
<folding />
|
349
|
+
</state>
|
350
|
+
</provider>
|
351
|
+
</entry>
|
352
|
+
<entry file="file://$PROJECT_DIR$/lib/piratebay_api/result_set.rb">
|
353
|
+
<provider selected="true" editor-type-id="text-editor">
|
354
|
+
<state vertical-scroll-proportion="0.0">
|
355
|
+
<caret line="16" column="5" selection-start-line="16" selection-start-column="5" selection-end-line="16" selection-end-column="5" />
|
356
|
+
<folding />
|
357
|
+
</state>
|
358
|
+
</provider>
|
359
|
+
</entry>
|
360
|
+
<entry file="file://$PROJECT_DIR$/lib/piratebay_api/version.rb">
|
361
|
+
<provider selected="true" editor-type-id="text-editor">
|
362
|
+
<state vertical-scroll-proportion="0.0">
|
363
|
+
<caret line="3" column="0" selection-start-line="3" selection-start-column="0" selection-end-line="3" selection-end-column="0" />
|
364
|
+
<folding />
|
365
|
+
</state>
|
366
|
+
</provider>
|
367
|
+
</entry>
|
368
|
+
<entry file="file://$PROJECT_DIR$/piratebay_api.gemspec">
|
369
|
+
<provider selected="true" editor-type-id="text-editor">
|
370
|
+
<state vertical-scroll-proportion="0.0">
|
371
|
+
<caret line="8" column="31" selection-start-line="8" selection-start-column="31" selection-end-line="8" selection-end-column="31" />
|
372
|
+
<folding />
|
373
|
+
</state>
|
374
|
+
</provider>
|
375
|
+
</entry>
|
376
|
+
<entry file="file://$PROJECT_DIR$/piratebay_api.gemspec">
|
377
|
+
<provider selected="true" editor-type-id="text-editor">
|
378
|
+
<state vertical-scroll-proportion="0.0">
|
379
|
+
<caret line="8" column="31" selection-start-line="8" selection-start-column="31" selection-end-line="8" selection-end-column="31" />
|
380
|
+
<folding />
|
381
|
+
</state>
|
382
|
+
</provider>
|
383
|
+
</entry>
|
384
|
+
<entry file="file://$PROJECT_DIR$/lib/piratebay_api/result_set.rb">
|
385
|
+
<provider selected="true" editor-type-id="text-editor">
|
386
|
+
<state vertical-scroll-proportion="0.0">
|
387
|
+
<caret line="16" column="5" selection-start-line="16" selection-start-column="5" selection-end-line="16" selection-end-column="5" />
|
388
|
+
<folding />
|
389
|
+
</state>
|
390
|
+
</provider>
|
391
|
+
</entry>
|
392
|
+
<entry file="file://$PROJECT_DIR$/lib/piratebay_api/version.rb">
|
393
|
+
<provider selected="true" editor-type-id="text-editor">
|
394
|
+
<state vertical-scroll-proportion="0.0">
|
395
|
+
<caret line="3" column="0" selection-start-line="3" selection-start-column="0" selection-end-line="3" selection-end-column="0" />
|
396
|
+
<folding />
|
397
|
+
</state>
|
398
|
+
</provider>
|
399
|
+
</entry>
|
400
|
+
<entry file="file://$PROJECT_DIR$/lib/piratebay_api/result.rb">
|
401
|
+
<provider selected="true" editor-type-id="text-editor">
|
402
|
+
<state vertical-scroll-proportion="0.0">
|
403
|
+
<caret line="5" column="17" selection-start-line="5" selection-start-column="8" selection-end-line="5" selection-end-column="17" />
|
404
|
+
<folding />
|
405
|
+
</state>
|
406
|
+
</provider>
|
407
|
+
</entry>
|
408
|
+
<entry file="file://$PROJECT_DIR$/lib/piratebay_api/details.rb">
|
409
|
+
<provider selected="true" editor-type-id="text-editor">
|
410
|
+
<state vertical-scroll-proportion="0.0">
|
411
|
+
<caret line="16" column="2" selection-start-line="16" selection-start-column="2" selection-end-line="16" selection-end-column="2" />
|
412
|
+
<folding />
|
413
|
+
</state>
|
414
|
+
</provider>
|
415
|
+
</entry>
|
416
|
+
<entry file="file://$PROJECT_DIR$/lib/piratebay_api/categories.rb">
|
417
|
+
<provider selected="true" editor-type-id="text-editor">
|
418
|
+
<state vertical-scroll-proportion="0.0">
|
419
|
+
<caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
|
420
|
+
<folding />
|
421
|
+
</state>
|
422
|
+
</provider>
|
423
|
+
</entry>
|
424
|
+
<entry file="file://$PROJECT_DIR$/lib/piratebay_api.rb">
|
425
|
+
<provider selected="true" editor-type-id="text-editor">
|
426
|
+
<state vertical-scroll-proportion="0.0">
|
427
|
+
<caret line="26" column="12" selection-start-line="26" selection-start-column="12" selection-end-line="26" selection-end-column="12" />
|
428
|
+
<folding />
|
429
|
+
</state>
|
430
|
+
</provider>
|
431
|
+
</entry>
|
432
|
+
<entry file="file://$PROJECT_DIR$/lib/piratebay_api/pirate_bay.rb">
|
433
|
+
<provider selected="true" editor-type-id="text-editor">
|
434
|
+
<state vertical-scroll-proportion="0.50163937">
|
435
|
+
<caret line="29" column="20" selection-start-line="29" selection-start-column="20" selection-end-line="29" selection-end-column="20" />
|
436
|
+
<folding />
|
437
|
+
</state>
|
438
|
+
</provider>
|
439
|
+
</entry>
|
440
|
+
</component>
|
441
|
+
</project>
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 Dani
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# PiratebayApi
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'piratebay_api'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install piratebay_api
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
TODO: Write usage instructions here
|
24
|
+
|
25
|
+
## Contributing
|
26
|
+
|
27
|
+
1. Fork it ( https://github.com/[my-github-username]/piratebay_api/fork )
|
28
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
29
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
30
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
31
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
module PirateBay
|
2
|
+
class Categories
|
3
|
+
EXTENDED_IDS = {
|
4
|
+
:MUSIC => 101,
|
5
|
+
:AUDIO_BOOKS => 102,
|
6
|
+
:SOUND_CLIPS => 103,
|
7
|
+
:FLAC => 104,
|
8
|
+
:MOVIES => 201,
|
9
|
+
:MOVIES_DVDR => 202,
|
10
|
+
:MUSIC_VIDEOS => 203,
|
11
|
+
:MOVIE_CLIPS => 204,
|
12
|
+
:TV_SHOWS => 205,
|
13
|
+
:HANDHELD => 206,
|
14
|
+
:HIGHRES_MOVIES => 207,
|
15
|
+
:HIGHRES_TV_SHOWS => 208,
|
16
|
+
:WINDOWS => 301,
|
17
|
+
:MAC => 302,
|
18
|
+
:UNIX => 303,
|
19
|
+
:HANDHELD => 304,
|
20
|
+
:OTHER_OS => 399,
|
21
|
+
:PC => 401,
|
22
|
+
:MAC => 402,
|
23
|
+
:PS2 => 403,
|
24
|
+
:XBOX360 => 404,
|
25
|
+
:WII => 405,
|
26
|
+
:HANDHELD => 406,
|
27
|
+
:OTHER => 499,
|
28
|
+
:MOVIES => 501,
|
29
|
+
:MOVIES_DVDR => 502,
|
30
|
+
:PICTURES => 503,
|
31
|
+
:GAMES => 504,
|
32
|
+
:HIGHRES_MOVIES => 505,
|
33
|
+
:MOVIE_CLIPS => 506,
|
34
|
+
:E_BOOKS => 601,
|
35
|
+
:COMICS => 602,
|
36
|
+
:PICTURES => 603,
|
37
|
+
:COVERS => 604,
|
38
|
+
}
|
39
|
+
|
40
|
+
IDS = {
|
41
|
+
ALL: 0,
|
42
|
+
:APPLICATION => 100,
|
43
|
+
:MOVIE => 200,
|
44
|
+
:AUDIO => 300,
|
45
|
+
:GAMES => 400,
|
46
|
+
:OTHER => 600
|
47
|
+
}
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,111 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'nokogiri'
|
3
|
+
module PirateBay
|
4
|
+
class Details
|
5
|
+
def to_s
|
6
|
+
"#<PirateBay::Details: @id=#{@id}>"
|
7
|
+
end
|
8
|
+
|
9
|
+
def initialize(html, type = :full)
|
10
|
+
@details_page_html = html
|
11
|
+
id_matches = html.match Regexp.new '<input type="hidden" name="id" value="(.*)"/>' rescue nil
|
12
|
+
@id = id_matches[1].to_i unless id_matches.nil?
|
13
|
+
@comment_pages_html = []
|
14
|
+
@scores = []
|
15
|
+
@type = type
|
16
|
+
end
|
17
|
+
|
18
|
+
def fetch_comments(params)
|
19
|
+
index = params[:page] - 1
|
20
|
+
if @comment_pages_html[index].nil?
|
21
|
+
uri = URI.parse('https://thepiratebay.se/ajax_details_comments.php')
|
22
|
+
res = Net::HTTP.post_form(uri, params)
|
23
|
+
response = res.body
|
24
|
+
@comment_pages_html[index] = response
|
25
|
+
end
|
26
|
+
@comment_pages_html[index]
|
27
|
+
end
|
28
|
+
|
29
|
+
def fetch_all_comments
|
30
|
+
comment_xhr_params.each do |params|
|
31
|
+
fetch_comments params
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def scores
|
36
|
+
if @type == :full
|
37
|
+
fetch_all_comments if @comment_pages_html.empty?
|
38
|
+
full_html = @comment_pages_html.inject('') { |html, memo| memo += html }
|
39
|
+
document = Nokogiri::HTML(full_html)
|
40
|
+
else
|
41
|
+
document = Nokogiri::HTML(@details_page_html)
|
42
|
+
end
|
43
|
+
|
44
|
+
scores = document.css('div.comment').map { |comment|
|
45
|
+
PirateBay::Details.search_for_ratings(comment.inner_html)
|
46
|
+
}
|
47
|
+
@scores = scores.reject { |r| r.empty? }
|
48
|
+
end
|
49
|
+
|
50
|
+
def comment_xhr_params
|
51
|
+
document = Nokogiri::HTML(@details_page_html)
|
52
|
+
comment_link = document.css('div.browse-coms a').first
|
53
|
+
if comment_link.nil?
|
54
|
+
[{ :page => 1, :pages => 1, :crc => '9b235c98e242f2617ae61dc416ec0de7', :id => @id }]
|
55
|
+
else
|
56
|
+
params = PirateBay::Details.extract_xhr_params comment_link.attr('onclick')
|
57
|
+
results = Array.new(params[:pages]) { |i| i+1 }
|
58
|
+
results.map do |i|
|
59
|
+
{ :page => i, :pages => params[:pages], :crc => params[:crc], :id => params[:id] }
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
|
65
|
+
def self.extract_xhr_params(string)
|
66
|
+
page, pages, crc, id = /comPage\((\d+),(\d+),'(.+)', '(.+)'\);/.match(string).captures
|
67
|
+
page = page.to_i
|
68
|
+
pages = pages.to_i
|
69
|
+
{ :page => page, :pages => pages, :crc => crc, :id => id }
|
70
|
+
end
|
71
|
+
|
72
|
+
|
73
|
+
def self.search_for_ratings string
|
74
|
+
video_score_matches = string.match(/(v|video) ?[:\=-]? ?([0-9]\.[0-9]|[0-9]{1,2})/i)
|
75
|
+
audio_score_matches = string.match(/(a|audio) ?[:\=-]? ?([0-9]\.[0-9]|[0-9]{1,2})/i)
|
76
|
+
ratings = {}
|
77
|
+
ratings[:v] = video_score_matches[2].to_f unless video_score_matches.nil?
|
78
|
+
ratings[:a] = audio_score_matches[2].to_f unless audio_score_matches.nil?
|
79
|
+
ratings.delete(:v) if ratings[:v] && ratings[:v] > 10
|
80
|
+
ratings.delete(:a) if ratings[:a] && ratings[:a] > 10
|
81
|
+
# puts "Incoming string of #{string} detected ratings of #{ratings}"
|
82
|
+
ratings
|
83
|
+
end
|
84
|
+
|
85
|
+
def video_scores
|
86
|
+
scores.map { |score| score[:v] }.compact
|
87
|
+
end
|
88
|
+
|
89
|
+
def video_quality_score_sum
|
90
|
+
video_scores.inject(0) { |score, memo| memo += score }
|
91
|
+
end
|
92
|
+
|
93
|
+
def video_quality_average
|
94
|
+
total_votes = [video_scores.size.to_f, 1].max
|
95
|
+
video_quality_score_sum / total_votes
|
96
|
+
end
|
97
|
+
|
98
|
+
def audio_scores
|
99
|
+
scores.map { |score| score[:a] }.compact
|
100
|
+
end
|
101
|
+
|
102
|
+
def audio_quality_score_sum
|
103
|
+
audio_scores.inject(0) { |score, memo| memo += score }
|
104
|
+
end
|
105
|
+
|
106
|
+
def audio_quality_average
|
107
|
+
total_votes = [audio_scores.size.to_f, 1].max.to_f
|
108
|
+
audio_quality_score_sum / total_votes
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
@@ -0,0 +1,105 @@
|
|
1
|
+
module PirateBay
|
2
|
+
class Search
|
3
|
+
attr_accessor :search_string, :category_id, :page, :caching, :results
|
4
|
+
BASE_URL = 'https://thepiratebay.se'
|
5
|
+
|
6
|
+
def initialize(search_string, category='movies')
|
7
|
+
@search_string = URI.encode(search_string)
|
8
|
+
@category_id = PirateBay::Categories::IDS[category.upcase.strip.gsub(/S$/, '').to_sym] unless category == 0
|
9
|
+
@page = -1
|
10
|
+
|
11
|
+
@results = PirateBay::ResultSet.new(self)
|
12
|
+
end
|
13
|
+
|
14
|
+
def get_search_results
|
15
|
+
if caching && File.exist?(cached_filename)
|
16
|
+
content = File.read(cached_filename)
|
17
|
+
else
|
18
|
+
content = fetch_search_results
|
19
|
+
|
20
|
+
FileUtils.mkdir_p('tmp/searches')
|
21
|
+
File.open(cached_filename, 'w') do |f|
|
22
|
+
f.write(content)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
content
|
26
|
+
end
|
27
|
+
|
28
|
+
def execute
|
29
|
+
return nil if search_string.nil?
|
30
|
+
self.page += 1
|
31
|
+
doc = ''
|
32
|
+
|
33
|
+
if @results.size < @results.total_results
|
34
|
+
doc = Nokogiri::HTML(get_search_results)
|
35
|
+
end
|
36
|
+
|
37
|
+
next_page(doc)
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
def sanitize_filename(filename)
|
42
|
+
filename = filename.gsub(/[^0-9A-Za-z.\-]/, 'x')
|
43
|
+
filename = filename.gsub(/^.*(\\|\/)/, '')
|
44
|
+
filename.strip
|
45
|
+
end
|
46
|
+
|
47
|
+
def cached_filename
|
48
|
+
File.join('tmp', 'searches', "#{sanitize_filename(search_string)}_#{category_id}_#{page}.html")
|
49
|
+
end
|
50
|
+
|
51
|
+
def get_quality
|
52
|
+
execute
|
53
|
+
results = @results.map do |result|
|
54
|
+
url = "#{BASE_URL}/torrent/#{result.id}/"
|
55
|
+
html = open(url).read
|
56
|
+
p = PirateBay::Details.new html, :init
|
57
|
+
puts 'Fetching results'
|
58
|
+
result = {
|
59
|
+
:seeds => result.seeds,
|
60
|
+
:size => result.size,
|
61
|
+
:name => result.name,
|
62
|
+
:video => p.video_quality_average,
|
63
|
+
:audio => p.audio_quality_average,
|
64
|
+
:url => url,
|
65
|
+
:video_votes => p.video_scores.size,
|
66
|
+
:audio_votes => p.audio_scores.size,
|
67
|
+
:video_votes_sum => p.video_quality_score_sum,
|
68
|
+
:audio_votes_sum => p.audio_quality_score_sum
|
69
|
+
}
|
70
|
+
puts "Results: #{result}"
|
71
|
+
result
|
72
|
+
end
|
73
|
+
|
74
|
+
results.reject { |a| a[:video].nan? }.sort_by { |a| a[:video] }
|
75
|
+
end
|
76
|
+
|
77
|
+
def fetch_search_results
|
78
|
+
url = "#{BASE_URL}/search/#{search_string}/#{page}/7/#{category_id}" # highest seeded first
|
79
|
+
open(url, { 'User-Agent' => 'libcurl-agent/1.0' }).read
|
80
|
+
end
|
81
|
+
|
82
|
+
private
|
83
|
+
|
84
|
+
def next_page(doc)
|
85
|
+
if @results.total_results.nil?
|
86
|
+
matching_results = doc.css('h2').first.content.match(/Displaying hits from (.*) to (.*) \(approx (.*) found\)/i)
|
87
|
+
|
88
|
+
if matching_results.nil?
|
89
|
+
@results.total_results = 0
|
90
|
+
else
|
91
|
+
@results.total_results = matching_results[3].to_i
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
doc.css('#searchResult tr').each_with_index do |row, index|
|
96
|
+
next if (index == 0)
|
97
|
+
next if (row.css('td').size <= 1)
|
98
|
+
result = PirateBay::Result.new(row)
|
99
|
+
@results << result
|
100
|
+
end
|
101
|
+
@results
|
102
|
+
end
|
103
|
+
|
104
|
+
end
|
105
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
module PirateBay
|
2
|
+
class Result
|
3
|
+
attr_accessor :id, :name, :seeds, :leeches, :category, :link, :magnet_link, :status, :size
|
4
|
+
|
5
|
+
def to_s
|
6
|
+
"<PirateBay::Result @name => #{name}, @seeds => #{seeds}, @size => #{size}>"
|
7
|
+
end
|
8
|
+
|
9
|
+
def initialize(row = nil)
|
10
|
+
if row.css('td')[1].css("img[alt='Trusted']").size > 0
|
11
|
+
status = 'Trusted'
|
12
|
+
elsif row.css('td')[1].css("img[alt='VIP']").size > 0
|
13
|
+
status = 'VIP'
|
14
|
+
else
|
15
|
+
status = nil
|
16
|
+
end
|
17
|
+
|
18
|
+
magnet_links = row.css('td')[1].css("a[title='Download this torrent using magnet']")
|
19
|
+
if magnet_links.size > 0
|
20
|
+
magnet_link = magnet_links.first[:href]
|
21
|
+
else
|
22
|
+
magnet_link = nil
|
23
|
+
end
|
24
|
+
|
25
|
+
self.id = row.inner_html.match(/torrent\/([\d]+)\//)[1]
|
26
|
+
self.name = row.css('.detName').first.content.strip
|
27
|
+
self.seeds = row.css('td')[2].content.to_i
|
28
|
+
self.leeches = row.css('td')[3].content.to_i
|
29
|
+
self.category = row.css('td')[0].css('a').map(&:content).join(' > ')
|
30
|
+
self.link = "https://torrents.thepiratebay.se/#{id}/#{name}.torrent"
|
31
|
+
self.magnet_link = magnet_link
|
32
|
+
self.status = status
|
33
|
+
|
34
|
+
raw_filesize = row.css('.detDesc').first.content.match(/Size (.*[G|M|K]iB)/i)[1]
|
35
|
+
self.size = filesize_in_bytes(raw_filesize)
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
def filesize_in_bytes(filesize)
|
40
|
+
match = filesize.match(/([\d.]+)(.*)/)
|
41
|
+
|
42
|
+
if match
|
43
|
+
raw_size = match[1].to_f
|
44
|
+
|
45
|
+
case match[2].strip
|
46
|
+
when /gib/i then
|
47
|
+
raw_size * 1000000000
|
48
|
+
when /mib/i then
|
49
|
+
raw_size * 1000000
|
50
|
+
when /kib/i then
|
51
|
+
raw_size * 1000
|
52
|
+
else
|
53
|
+
nil
|
54
|
+
end
|
55
|
+
else
|
56
|
+
nil
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module PirateBay
|
2
|
+
class ResultSet < Array
|
3
|
+
attr_accessor :total_results, :search
|
4
|
+
|
5
|
+
def initialize(initializer)
|
6
|
+
self.search = initializer
|
7
|
+
self.total_results = 1.0/0 #Infinity
|
8
|
+
end
|
9
|
+
|
10
|
+
def retrieved_results
|
11
|
+
self.size
|
12
|
+
end
|
13
|
+
|
14
|
+
def more
|
15
|
+
search.next_page
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'piratebay_api/version'
|
2
|
+
require 'rubygems'
|
3
|
+
|
4
|
+
require 'fileutils'
|
5
|
+
require 'net/http'
|
6
|
+
|
7
|
+
require 'hpricot'
|
8
|
+
require 'open-uri'
|
9
|
+
|
10
|
+
require 'nokogiri'
|
11
|
+
require 'uri'
|
12
|
+
|
13
|
+
%w(result pirate_bay categories details result_set).each do |filename|
|
14
|
+
require File.join(File.dirname(__FILE__), 'piratebay_api', filename)
|
15
|
+
end
|
16
|
+
|
17
|
+
class PiratebayApi
|
18
|
+
attr_accessor :service, :search_term, :results
|
19
|
+
|
20
|
+
def initialize(service=:pirate_bay, search_term=nil)
|
21
|
+
@service = service
|
22
|
+
@search_term = search_term
|
23
|
+
|
24
|
+
@results = search if @search_term
|
25
|
+
end
|
26
|
+
|
27
|
+
def search
|
28
|
+
if @service == :all
|
29
|
+
results = []
|
30
|
+
results << PirateBay::Search.new(@search_term).execute
|
31
|
+
results = results.flatten.sort_by { |sort| -(sort.seeds) }
|
32
|
+
else
|
33
|
+
case @service
|
34
|
+
when :pirate_bay
|
35
|
+
handler = PirateBay::Search.new(@search_term)
|
36
|
+
else
|
37
|
+
raise 'You must select a valid service provider'
|
38
|
+
end
|
39
|
+
|
40
|
+
results = handler.execute
|
41
|
+
end
|
42
|
+
@results = results
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'piratebay_api/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'piratebay_api'
|
8
|
+
spec.version = PiratebayApi::VERSION
|
9
|
+
spec.authors = ['Dani']
|
10
|
+
spec.email = ['gomess13@bitbucket.org']
|
11
|
+
spec.summary = %q{Allow to retrieve result search from pirate bay.}
|
12
|
+
spec.description = %q{}
|
13
|
+
spec.homepage = ''
|
14
|
+
spec.license = 'MIT'
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ['lib']
|
20
|
+
|
21
|
+
spec.add_runtime_dependency 'nokogiri'
|
22
|
+
spec.add_runtime_dependency 'hpricot', '~> 0'
|
23
|
+
spec.add_runtime_dependency 'awesome_print', '~> 0'
|
24
|
+
|
25
|
+
spec.add_development_dependency 'bundler', '~> 1.7'
|
26
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
27
|
+
end
|
metadata
ADDED
@@ -0,0 +1,132 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: piratebay_api
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Dani
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-05-12 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: nokogiri
|
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: hpricot
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: awesome_print
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: bundler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.7'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.7'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '10.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '10.0'
|
83
|
+
description: ''
|
84
|
+
email:
|
85
|
+
- gomess13@bitbucket.org
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- ".gitignore"
|
91
|
+
- ".idea/misc.xml"
|
92
|
+
- ".idea/modules.xml"
|
93
|
+
- ".idea/piratebay_api.iml"
|
94
|
+
- ".idea/vcs.xml"
|
95
|
+
- ".idea/workspace.xml"
|
96
|
+
- Gemfile
|
97
|
+
- LICENSE.txt
|
98
|
+
- README.md
|
99
|
+
- Rakefile
|
100
|
+
- lib/piratebay_api.rb
|
101
|
+
- lib/piratebay_api/categories.rb
|
102
|
+
- lib/piratebay_api/details.rb
|
103
|
+
- lib/piratebay_api/pirate_bay.rb
|
104
|
+
- lib/piratebay_api/result.rb
|
105
|
+
- lib/piratebay_api/result_set.rb
|
106
|
+
- lib/piratebay_api/version.rb
|
107
|
+
- piratebay_api.gemspec
|
108
|
+
homepage: ''
|
109
|
+
licenses:
|
110
|
+
- MIT
|
111
|
+
metadata: {}
|
112
|
+
post_install_message:
|
113
|
+
rdoc_options: []
|
114
|
+
require_paths:
|
115
|
+
- lib
|
116
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
117
|
+
requirements:
|
118
|
+
- - ">="
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: '0'
|
121
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
122
|
+
requirements:
|
123
|
+
- - ">="
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
126
|
+
requirements: []
|
127
|
+
rubyforge_project:
|
128
|
+
rubygems_version: 2.2.2
|
129
|
+
signing_key:
|
130
|
+
specification_version: 4
|
131
|
+
summary: Allow to retrieve result search from pirate bay.
|
132
|
+
test_files: []
|