-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWeb.rb
143 lines (104 loc) · 3.79 KB
/
Web.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
module MyTV
class Web
# ************************************************************+
# ** TVMaze **
# ************************************************************+
TVMAZE_URL = "http://api.tvmaze.com"
def Web.get_show_id(show_name)
url = TVMAZE_URL + "/singlesearch/shows?q=" + show_name # &embed=episodes
agent = Mechanize.new
page = agent.get(url).content
obj = JSON.parse(page)
obj['id']
end
##
# "id"=>2244
# "status"=>"Running"
# "schedule"=>{"time"=>"22:00", "days"=>["Thursday"]}
# "updated"=>1443264033
# "_links"=>{previousepisode"=>{"href"=>"http://api.tvmaze.com/episodes/182003"}, "nextepisode"=>{"href"=>"http://api.tvmaze.com/episodes/215496"}}
def Web.search_show(show_name)
url = TVMAZE_URL + "/singlesearch/shows?q=" + show_name # &embed=episodes
agent = Mechanize.new
page = agent.get(url).content
obj = JSON.parse(page)
return obj
end
def Web.get_episodes(showID)
url = TVMAZE_URL + "/shows/" + showID.to_s + "/episodes" #?specials=1
agent = Mechanize.new
page = agent.get(url).content
obj = JSON.parse(page)
return obj
end
# ************************************************************+
# ** RARBG **
# ************************************************************+
# Choose 720p
TPB_URL = "https://thehiddenbay.me/search/"
GROUPS = ["LOL", "BATV", "DIMENSION", "FLEET", "KILLERS"]
def Web.get_magnet_link(season, episode, showname)
search = Array.new
search << showname.split(" ")
if season.to_i < 10
seasonnum = "S0" + season.to_s
else
seasonnum = "S" + season.to_s
end
search << seasonnum
if episode.to_i < 10
epnum = "E0" + episode.to_s
else
epnum = "E" + episode.to_s
end
search = search.join("+")
search << epnum
# Add ettv/rartv?
search << "/0/7/0"
uri = TPB_URL + search.to_s
agent = Mechanize.new
page = agent.get(uri)
page.links_with(:text => "Magnet link")[0].href
# Parse for: table id searchResult
# tbody > tr > td (second one) > first link
# or tbody > tr > td (second one) > div detname > first link.click > parse new page
rescue => e
$logger.error("Exception in get_magnet_link : " + e.message + " [" + e.class.to_s + "]")
puts "Error: " + e.message + " [" + e.class.to_s + "]"
end
def Web.get_torrent_link()
end
# ************************************************************+
# ** Addic7ed **
# ************************************************************+
ADD_URL = "http://Addic7ed.org"
def get_subtitles()
uri = ADD_URL# Full url
agent = Mechanize.new
page = agent.get(uri)
rescue => e
$logger.error("Exception in get_subtitles : " + e.message + " [" + e.class.to_s + "]")
puts "Error: " + e.message + " [" + e.class.to_s + "]"
end
end
end
=begin
<tr class="lista2">
<td align="left" class="lista" width="48" style="width:48px;">
<a href="/torrents.php?category=18"><img src="//dyncdn.me/static/20/images/categories/cat_new18.gif" border="0" alt="" /></a></td>
<td align="left" class="lista">
<a onmouseover="return overlib('<img src=\'//dyncdn.me/static/20/tvdb/314002_small.jpg\' border=0>')" onmouseout="return nd();"
href="/torrent/kh6l95s" title="The Player 2015 S01E01 HDTV XviD-FUM[ettv]">
def Web.searchShow(show_name)
url = TVMAZE_URL + "/search/shows?q=" + show_name
resp = Net::HTTP.get_response(URI.parse(url))
resp_text = resp.body
obj = JSON.parse(resp_text)
end
def Web.getSchedule(date) # YYYY-MM-DD
url = TVMAZE_URL + "/schedule?country=US&date=" + date
resp = Net::HTTP.get_response(URI.parse(url))
resp_text = resp.body
obj = JSON.parse(resp_text)
end
=end