subdl 0.0.7 → 0.0.8
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/lib/subdl.rb +16 -9
- 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: 88749b74dbf27dfdba46db301bbeb2d302c8ee78
|
4
|
+
data.tar.gz: f2e8bbc9698a7b8470e4e4b01478d31a9ab1a102
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: af183442e79790255ef4f9b5703b2bf331f3a13ac9e459a63594dc8d11c67b82dab9746c81d2936f2ac7bbd91f802c2ffc9daa3696edce0272def174c940074d
|
7
|
+
data.tar.gz: d166c4af0f2e0a98366ad5e52e173a84a500d5390da7047878a7fc4b8f62762eb43fab7589af37b844219588c83c853c0d2d1b8ade1500e6afa14fe7fb9092a0
|
data/lib/subdl.rb
CHANGED
@@ -31,6 +31,10 @@ class Crawler
|
|
31
31
|
movie_file = MovieFile.new path, @stdout
|
32
32
|
ids = @itasa.search_subtitles(movie_file.search_term)
|
33
33
|
|
34
|
+
if not ids.any?
|
35
|
+
@stdout.puts "No subtitles found on Itasa for: #{path}"
|
36
|
+
end
|
37
|
+
|
34
38
|
ids.each do |id|
|
35
39
|
@itasa.login *@credentials.read
|
36
40
|
@itasa.download_zip id do |zip_contents|
|
@@ -142,20 +146,11 @@ class Itasa
|
|
142
146
|
@login_form.login username, password, "http://#{host}", @agent
|
143
147
|
end
|
144
148
|
|
145
|
-
def autocomplete_data_for text
|
146
|
-
response = @agent.get search_url(text)
|
147
|
-
response.body
|
148
|
-
end
|
149
|
-
|
150
149
|
def search_subtitles text
|
151
150
|
json = autocomplete_data_for text
|
152
151
|
return extract_ids_from_autocomplete_data json
|
153
152
|
end
|
154
153
|
|
155
|
-
def extract_ids_from_autocomplete_data json
|
156
|
-
JSON.parse(json).map { |episode| episode['id'] }
|
157
|
-
end
|
158
|
-
|
159
154
|
def download_zip id
|
160
155
|
page = @agent.get subtitle_page_url(id)
|
161
156
|
zipped_subtitle = @agent.get subtitle_zip_url(page.body)
|
@@ -178,6 +173,18 @@ class Itasa
|
|
178
173
|
"&id=#{id}")
|
179
174
|
end
|
180
175
|
|
176
|
+
private
|
177
|
+
|
178
|
+
def autocomplete_data_for text
|
179
|
+
response = @agent.get search_url(text)
|
180
|
+
response.body
|
181
|
+
end
|
182
|
+
|
183
|
+
def extract_ids_from_autocomplete_data json
|
184
|
+
return [] if json == 'null'
|
185
|
+
JSON.parse(json).map { |episode| episode['id'] }
|
186
|
+
end
|
187
|
+
|
181
188
|
def host
|
182
189
|
'www.italiansubs.net'
|
183
190
|
end
|