piratebay_api 0.1.1 → 0.1.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 +4 -4
- data/.idea/workspace.xml +50 -47
- data/lib/piratebay_api/details.rb +3 -2
- data/lib/piratebay_api/pirate_bay.rb +3 -3
- data/lib/piratebay_api/result.rb +4 -2
- data/lib/piratebay_api/version.rb +1 -1
- data/lib/piratebay_api.rb +4 -3
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1ffb1c036f89abc5dd1ffe5e66e044e35fd17953
|
|
4
|
+
data.tar.gz: d206815d0aa4e000668fefc5d1133352bd000b66
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8b1a1e5d3597171528f7541e45002604c25124eaaefdde416aba7301983c891edf1bcc810ee3105930efedb774960ca4b560669829e8088f7036b24e8d38adc1
|
|
7
|
+
data.tar.gz: 3303317ecf6a803f5768bd4af0cc1fc8f7b05c6fc52a67f132982b1cadc8a7018d890edfdac1e09bdc56737c07664ec14450565dd9821d5da542fe2dd16398a7
|
data/.idea/workspace.xml
CHANGED
|
@@ -2,7 +2,10 @@
|
|
|
2
2
|
<project version="4">
|
|
3
3
|
<component name="ChangeListManager">
|
|
4
4
|
<list default="true" id="da40877e-0aec-4a2e-867f-ad9195b4be60" name="Default" comment="">
|
|
5
|
+
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/lib/piratebay_api/details.rb" afterPath="$PROJECT_DIR$/lib/piratebay_api/details.rb" />
|
|
5
6
|
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/lib/piratebay_api/pirate_bay.rb" afterPath="$PROJECT_DIR$/lib/piratebay_api/pirate_bay.rb" />
|
|
7
|
+
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/lib/piratebay_api.rb" afterPath="$PROJECT_DIR$/lib/piratebay_api.rb" />
|
|
8
|
+
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/lib/piratebay_api/result.rb" afterPath="$PROJECT_DIR$/lib/piratebay_api/result.rb" />
|
|
6
9
|
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/lib/piratebay_api/version.rb" afterPath="$PROJECT_DIR$/lib/piratebay_api/version.rb" />
|
|
7
10
|
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/workspace.xml" afterPath="$PROJECT_DIR$/.idea/workspace.xml" />
|
|
8
11
|
</list>
|
|
@@ -30,17 +33,7 @@
|
|
|
30
33
|
<entry file="file://$PROJECT_DIR$/lib/piratebay_api.rb">
|
|
31
34
|
<provider selected="true" editor-type-id="text-editor">
|
|
32
35
|
<state vertical-scroll-proportion="0.0">
|
|
33
|
-
<caret line="
|
|
34
|
-
<folding />
|
|
35
|
-
</state>
|
|
36
|
-
</provider>
|
|
37
|
-
</entry>
|
|
38
|
-
</file>
|
|
39
|
-
<file leaf-file-name="categories.rb" pinned="false" current-in-tab="false">
|
|
40
|
-
<entry file="file://$PROJECT_DIR$/lib/piratebay_api/categories.rb">
|
|
41
|
-
<provider selected="true" editor-type-id="text-editor">
|
|
42
|
-
<state vertical-scroll-proportion="0.0">
|
|
43
|
-
<caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
|
|
36
|
+
<caret line="28" column="23" selection-start-line="28" selection-start-column="23" selection-end-line="28" selection-end-column="23" />
|
|
44
37
|
<folding />
|
|
45
38
|
</state>
|
|
46
39
|
</provider>
|
|
@@ -50,27 +43,27 @@
|
|
|
50
43
|
<entry file="file://$PROJECT_DIR$/lib/piratebay_api/details.rb">
|
|
51
44
|
<provider selected="true" editor-type-id="text-editor">
|
|
52
45
|
<state vertical-scroll-proportion="0.0">
|
|
53
|
-
<caret line="
|
|
46
|
+
<caret line="17" column="2" selection-start-line="17" selection-start-column="2" selection-end-line="17" selection-end-column="2" />
|
|
54
47
|
<folding />
|
|
55
48
|
</state>
|
|
56
49
|
</provider>
|
|
57
50
|
</entry>
|
|
58
51
|
</file>
|
|
59
|
-
<file leaf-file-name="
|
|
60
|
-
<entry file="file://$PROJECT_DIR$/lib/piratebay_api/
|
|
52
|
+
<file leaf-file-name="result.rb" pinned="false" current-in-tab="false">
|
|
53
|
+
<entry file="file://$PROJECT_DIR$/lib/piratebay_api/result.rb">
|
|
61
54
|
<provider selected="true" editor-type-id="text-editor">
|
|
62
55
|
<state vertical-scroll-proportion="0.0">
|
|
63
|
-
<caret line="
|
|
56
|
+
<caret line="2" column="94" selection-start-line="2" selection-start-column="94" selection-end-line="2" selection-end-column="94" />
|
|
64
57
|
<folding />
|
|
65
58
|
</state>
|
|
66
59
|
</provider>
|
|
67
60
|
</entry>
|
|
68
61
|
</file>
|
|
69
|
-
<file leaf-file-name="
|
|
70
|
-
<entry file="file://$PROJECT_DIR$/lib/piratebay_api/
|
|
62
|
+
<file leaf-file-name="pirate_bay.rb" pinned="false" current-in-tab="false">
|
|
63
|
+
<entry file="file://$PROJECT_DIR$/lib/piratebay_api/pirate_bay.rb">
|
|
71
64
|
<provider selected="true" editor-type-id="text-editor">
|
|
72
65
|
<state vertical-scroll-proportion="0.0">
|
|
73
|
-
<caret line="
|
|
66
|
+
<caret line="15" column="48" selection-start-line="15" selection-start-column="48" selection-end-line="15" selection-end-column="48" />
|
|
74
67
|
<folding />
|
|
75
68
|
</state>
|
|
76
69
|
</provider>
|
|
@@ -80,7 +73,7 @@
|
|
|
80
73
|
<entry file="file://$PROJECT_DIR$/lib/piratebay_api/result_set.rb">
|
|
81
74
|
<provider selected="true" editor-type-id="text-editor">
|
|
82
75
|
<state vertical-scroll-proportion="0.0">
|
|
83
|
-
<caret line="
|
|
76
|
+
<caret line="6" column="22" selection-start-line="6" selection-start-column="22" selection-end-line="6" selection-end-column="22" />
|
|
84
77
|
<folding />
|
|
85
78
|
</state>
|
|
86
79
|
</provider>
|
|
@@ -89,8 +82,8 @@
|
|
|
89
82
|
<file leaf-file-name="version.rb" pinned="false" current-in-tab="true">
|
|
90
83
|
<entry file="file://$PROJECT_DIR$/lib/piratebay_api/version.rb">
|
|
91
84
|
<provider selected="true" editor-type-id="text-editor">
|
|
92
|
-
<state vertical-scroll-proportion="0.
|
|
93
|
-
<caret line="
|
|
85
|
+
<state vertical-scroll-proportion="0.027777778">
|
|
86
|
+
<caret line="1" column="18" selection-start-line="1" selection-start-column="18" selection-end-line="1" selection-end-column="18" />
|
|
94
87
|
<folding />
|
|
95
88
|
</state>
|
|
96
89
|
</provider>
|
|
@@ -106,6 +99,16 @@
|
|
|
106
99
|
</provider>
|
|
107
100
|
</entry>
|
|
108
101
|
</file>
|
|
102
|
+
<file leaf-file-name="categories.rb" pinned="false" current-in-tab="false">
|
|
103
|
+
<entry file="file://$PROJECT_DIR$/lib/piratebay_api/categories.rb">
|
|
104
|
+
<provider selected="true" editor-type-id="text-editor">
|
|
105
|
+
<state vertical-scroll-proportion="0.0">
|
|
106
|
+
<caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
|
|
107
|
+
<folding />
|
|
108
|
+
</state>
|
|
109
|
+
</provider>
|
|
110
|
+
</entry>
|
|
111
|
+
</file>
|
|
109
112
|
</leaf>
|
|
110
113
|
</component>
|
|
111
114
|
<component name="Git.Settings">
|
|
@@ -115,9 +118,9 @@
|
|
|
115
118
|
<option name="CHANGED_PATHS">
|
|
116
119
|
<list>
|
|
117
120
|
<option value="$PROJECT_DIR$/piratebay_api.gemspec" />
|
|
118
|
-
<option value="$PROJECT_DIR$/lib/piratebay_api.rb" />
|
|
119
|
-
<option value="$PROJECT_DIR$/lib/piratebay_api/result.rb" />
|
|
120
121
|
<option value="$PROJECT_DIR$/lib/piratebay_api/details.rb" />
|
|
122
|
+
<option value="$PROJECT_DIR$/lib/piratebay_api/result.rb" />
|
|
123
|
+
<option value="$PROJECT_DIR$/lib/piratebay_api.rb" />
|
|
121
124
|
<option value="$PROJECT_DIR$/lib/piratebay_api/pirate_bay.rb" />
|
|
122
125
|
<option value="$PROJECT_DIR$/lib/piratebay_api/version.rb" />
|
|
123
126
|
</list>
|
|
@@ -131,10 +134,10 @@
|
|
|
131
134
|
<order />
|
|
132
135
|
</component>
|
|
133
136
|
<component name="ProjectFrameBounds">
|
|
134
|
-
<option name="x" value="-
|
|
135
|
-
<option name="y" value="
|
|
136
|
-
<option name="width" value="
|
|
137
|
-
<option name="height" value="
|
|
137
|
+
<option name="x" value="-8" />
|
|
138
|
+
<option name="y" value="-8" />
|
|
139
|
+
<option name="width" value="1936" />
|
|
140
|
+
<option name="height" value="1056" />
|
|
138
141
|
</component>
|
|
139
142
|
<component name="ProjectLevelVcsManager" settingsEditedManually="true">
|
|
140
143
|
<OptionsSetting value="true" id="Add" />
|
|
@@ -273,24 +276,24 @@
|
|
|
273
276
|
</todo-panel>
|
|
274
277
|
</component>
|
|
275
278
|
<component name="ToolWindowManager">
|
|
276
|
-
<frame x="-
|
|
279
|
+
<frame x="-8" y="-8" width="1936" height="1056" extended-state="6" />
|
|
277
280
|
<editor active="true" />
|
|
278
281
|
<layout>
|
|
279
|
-
<window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.
|
|
282
|
+
<window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.3263158" sideWeight="0.48294243" order="7" side_tool="false" content_ui="tabs" />
|
|
280
283
|
<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" />
|
|
281
284
|
<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" />
|
|
282
285
|
<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" />
|
|
283
|
-
<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="
|
|
284
|
-
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.
|
|
286
|
+
<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="11" side_tool="false" content_ui="tabs" />
|
|
287
|
+
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.26066098" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" />
|
|
285
288
|
<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" />
|
|
286
|
-
<window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.
|
|
287
|
-
<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="
|
|
289
|
+
<window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.3263158" sideWeight="0.5170576" order="8" side_tool="true" content_ui="tabs" />
|
|
290
|
+
<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="9" side_tool="false" content_ui="tabs" />
|
|
288
291
|
<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" />
|
|
289
292
|
<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" />
|
|
290
293
|
<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" />
|
|
291
294
|
<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" />
|
|
292
295
|
<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" />
|
|
293
|
-
<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="
|
|
296
|
+
<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="10" side_tool="false" content_ui="tabs" />
|
|
294
297
|
<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" />
|
|
295
298
|
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.32842106" sideWeight="0.4936034" order="2" side_tool="false" content_ui="tabs" />
|
|
296
299
|
<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" />
|
|
@@ -505,10 +508,10 @@
|
|
|
505
508
|
</state>
|
|
506
509
|
</provider>
|
|
507
510
|
</entry>
|
|
508
|
-
<entry file="file://$PROJECT_DIR$/
|
|
511
|
+
<entry file="file://$PROJECT_DIR$/piratebay_api.gemspec">
|
|
509
512
|
<provider selected="true" editor-type-id="text-editor">
|
|
510
513
|
<state vertical-scroll-proportion="0.0">
|
|
511
|
-
<caret line="
|
|
514
|
+
<caret line="8" column="31" selection-start-line="8" selection-start-column="31" selection-end-line="8" selection-end-column="31" />
|
|
512
515
|
<folding />
|
|
513
516
|
</state>
|
|
514
517
|
</provider>
|
|
@@ -521,34 +524,34 @@
|
|
|
521
524
|
</state>
|
|
522
525
|
</provider>
|
|
523
526
|
</entry>
|
|
524
|
-
<entry file="file://$PROJECT_DIR$/lib/piratebay_api
|
|
527
|
+
<entry file="file://$PROJECT_DIR$/lib/piratebay_api.rb">
|
|
525
528
|
<provider selected="true" editor-type-id="text-editor">
|
|
526
529
|
<state vertical-scroll-proportion="0.0">
|
|
527
|
-
<caret line="
|
|
530
|
+
<caret line="28" column="23" selection-start-line="28" selection-start-column="23" selection-end-line="28" selection-end-column="23" />
|
|
528
531
|
<folding />
|
|
529
532
|
</state>
|
|
530
533
|
</provider>
|
|
531
534
|
</entry>
|
|
532
|
-
<entry file="file://$PROJECT_DIR$/lib/piratebay_api/
|
|
535
|
+
<entry file="file://$PROJECT_DIR$/lib/piratebay_api/details.rb">
|
|
533
536
|
<provider selected="true" editor-type-id="text-editor">
|
|
534
537
|
<state vertical-scroll-proportion="0.0">
|
|
535
|
-
<caret line="
|
|
538
|
+
<caret line="17" column="2" selection-start-line="17" selection-start-column="2" selection-end-line="17" selection-end-column="2" />
|
|
536
539
|
<folding />
|
|
537
540
|
</state>
|
|
538
541
|
</provider>
|
|
539
542
|
</entry>
|
|
540
|
-
<entry file="file://$PROJECT_DIR$/lib/piratebay_api.rb">
|
|
543
|
+
<entry file="file://$PROJECT_DIR$/lib/piratebay_api/result_set.rb">
|
|
541
544
|
<provider selected="true" editor-type-id="text-editor">
|
|
542
545
|
<state vertical-scroll-proportion="0.0">
|
|
543
|
-
<caret line="
|
|
546
|
+
<caret line="6" column="22" selection-start-line="6" selection-start-column="22" selection-end-line="6" selection-end-column="22" />
|
|
544
547
|
<folding />
|
|
545
548
|
</state>
|
|
546
549
|
</provider>
|
|
547
550
|
</entry>
|
|
548
|
-
<entry file="file://$PROJECT_DIR$/piratebay_api.
|
|
551
|
+
<entry file="file://$PROJECT_DIR$/lib/piratebay_api/result.rb">
|
|
549
552
|
<provider selected="true" editor-type-id="text-editor">
|
|
550
553
|
<state vertical-scroll-proportion="0.0">
|
|
551
|
-
<caret line="
|
|
554
|
+
<caret line="2" column="94" selection-start-line="2" selection-start-column="94" selection-end-line="2" selection-end-column="94" />
|
|
552
555
|
<folding />
|
|
553
556
|
</state>
|
|
554
557
|
</provider>
|
|
@@ -556,15 +559,15 @@
|
|
|
556
559
|
<entry file="file://$PROJECT_DIR$/lib/piratebay_api/pirate_bay.rb">
|
|
557
560
|
<provider selected="true" editor-type-id="text-editor">
|
|
558
561
|
<state vertical-scroll-proportion="0.0">
|
|
559
|
-
<caret line="
|
|
562
|
+
<caret line="15" column="48" selection-start-line="15" selection-start-column="48" selection-end-line="15" selection-end-column="48" />
|
|
560
563
|
<folding />
|
|
561
564
|
</state>
|
|
562
565
|
</provider>
|
|
563
566
|
</entry>
|
|
564
567
|
<entry file="file://$PROJECT_DIR$/lib/piratebay_api/version.rb">
|
|
565
568
|
<provider selected="true" editor-type-id="text-editor">
|
|
566
|
-
<state vertical-scroll-proportion="0.
|
|
567
|
-
<caret line="
|
|
569
|
+
<state vertical-scroll-proportion="0.027777778">
|
|
570
|
+
<caret line="1" column="18" selection-start-line="1" selection-start-column="18" selection-end-line="1" selection-end-column="18" />
|
|
568
571
|
<folding />
|
|
569
572
|
</state>
|
|
570
573
|
</provider>
|
|
@@ -6,19 +6,20 @@ module PirateBay
|
|
|
6
6
|
"#<PirateBay::Details: @id=#{@id}>"
|
|
7
7
|
end
|
|
8
8
|
|
|
9
|
-
def initialize(html, type = :full)
|
|
9
|
+
def initialize(html, type = :full, url)
|
|
10
10
|
@details_page_html = html
|
|
11
11
|
id_matches = html.match Regexp.new '<input type="hidden" name="id" value="(.*)"/>' rescue nil
|
|
12
12
|
@id = id_matches[1].to_i unless id_matches.nil?
|
|
13
13
|
@comment_pages_html = []
|
|
14
14
|
@scores = []
|
|
15
15
|
@type = type
|
|
16
|
+
@base_url = url
|
|
16
17
|
end
|
|
17
18
|
|
|
18
19
|
def fetch_comments(params)
|
|
19
20
|
index = params[:page] - 1
|
|
20
21
|
if @comment_pages_html[index].nil?
|
|
21
|
-
uri = URI.parse('
|
|
22
|
+
uri = URI.parse(@base_url + '/ajax_details_comments.php')
|
|
22
23
|
res = Net::HTTP.post_form(uri, params)
|
|
23
24
|
response = res.body
|
|
24
25
|
@comment_pages_html[index] = response
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
module PirateBay
|
|
2
2
|
class Search
|
|
3
|
-
attr_accessor :search_string, :category_id, :page, :caching, :results
|
|
3
|
+
attr_accessor :search_string, :category_id, :page, :caching, :results, :base_url
|
|
4
4
|
|
|
5
5
|
public
|
|
6
6
|
def initialize(search_string, category=0, url='https://thepiratebay.se')
|
|
@@ -54,7 +54,7 @@ module PirateBay
|
|
|
54
54
|
results = @results.map do |result|
|
|
55
55
|
url = "#{@base_url}/torrent/#{result.id}/"
|
|
56
56
|
html = open(url).read
|
|
57
|
-
p = PirateBay::Details.new html, :init
|
|
57
|
+
p = PirateBay::Details.new html, :init, @base_url
|
|
58
58
|
puts 'Fetching results'
|
|
59
59
|
result = {
|
|
60
60
|
:seeds => result.seeds,
|
|
@@ -96,7 +96,7 @@ module PirateBay
|
|
|
96
96
|
doc.css('#searchResult tr').each_with_index do |row, index|
|
|
97
97
|
next if (index == 0)
|
|
98
98
|
next if (row.css('td').size <= 1)
|
|
99
|
-
result = PirateBay::Result.new(row)
|
|
99
|
+
result = PirateBay::Result.new(row, @base_url)
|
|
100
100
|
@results << result
|
|
101
101
|
end
|
|
102
102
|
@results
|
data/lib/piratebay_api/result.rb
CHANGED
|
@@ -6,7 +6,7 @@ module PirateBay
|
|
|
6
6
|
"<PirateBay::Result @name => #{name}, @seeds => #{seeds}, @size => #{size}>"
|
|
7
7
|
end
|
|
8
8
|
|
|
9
|
-
def initialize(row = nil)
|
|
9
|
+
def initialize(row = nil, url)
|
|
10
10
|
if row.css('td')[1].css("img[alt='Trusted']").size > 0
|
|
11
11
|
status = 'Trusted'
|
|
12
12
|
elsif row.css('td')[1].css("img[alt='VIP']").size > 0
|
|
@@ -22,12 +22,14 @@ module PirateBay
|
|
|
22
22
|
magnet_link = nil
|
|
23
23
|
end
|
|
24
24
|
|
|
25
|
+
domain = url.split('.')[1]
|
|
26
|
+
|
|
25
27
|
self.id = row.inner_html.match(/torrent\/([\d]+)\//)[1]
|
|
26
28
|
self.name = row.css('.detName').first.content.strip
|
|
27
29
|
self.seeds = row.css('td')[2].content.to_i
|
|
28
30
|
self.leeches = row.css('td')[3].content.to_i
|
|
29
31
|
self.category = row.css('td')[0].css('a').map(&:content).join(' > ')
|
|
30
|
-
self.link =
|
|
32
|
+
self.link = 'https://torrents.thepiratebay.' + domain + "/#{id}/#{name}.torrent"
|
|
31
33
|
self.magnet_link = magnet_link
|
|
32
34
|
self.status = status
|
|
33
35
|
|
data/lib/piratebay_api.rb
CHANGED
|
@@ -17,9 +17,10 @@ end
|
|
|
17
17
|
class PiratebayApi
|
|
18
18
|
attr_accessor :service, :search_term, :results
|
|
19
19
|
|
|
20
|
-
def initialize(service=:pirate_bay, search_term=nil)
|
|
20
|
+
def initialize(service=:pirate_bay, search_term=nil, url)
|
|
21
21
|
@service = service
|
|
22
22
|
@search_term = search_term
|
|
23
|
+
@base_url = url
|
|
23
24
|
|
|
24
25
|
@results = search if @search_term
|
|
25
26
|
end
|
|
@@ -27,12 +28,12 @@ class PiratebayApi
|
|
|
27
28
|
def search
|
|
28
29
|
if @service == :all
|
|
29
30
|
results = []
|
|
30
|
-
results << PirateBay::Search.new(@search_term).execute
|
|
31
|
+
results << PirateBay::Search.new(@search_term, 0, @base_url).execute
|
|
31
32
|
results = results.flatten.sort_by { |sort| -(sort.seeds) }
|
|
32
33
|
else
|
|
33
34
|
case @service
|
|
34
35
|
when :pirate_bay
|
|
35
|
-
handler = PirateBay::Search.new(@search_term)
|
|
36
|
+
handler = PirateBay::Search.new(@search_term, 0, @base_url)
|
|
36
37
|
else
|
|
37
38
|
raise 'You must select a valid service provider'
|
|
38
39
|
end
|