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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/subdl.rb +16 -9
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b353f0e19e883d57a353f5ea315cc4d6ef1a71e6
4
- data.tar.gz: b81266cb82694395f3b86f77bbee9a69f8723271
3
+ metadata.gz: 88749b74dbf27dfdba46db301bbeb2d302c8ee78
4
+ data.tar.gz: f2e8bbc9698a7b8470e4e4b01478d31a9ab1a102
5
5
  SHA512:
6
- metadata.gz: f67572d0e484e3055ee9d61f389a9a16274bcffd9c3beee96389364e5a9cd43688523fb49c2c27fee8829b16d480e58b833b96b2dd90632f1aac89c9a09522db
7
- data.tar.gz: cc0219092a9b21f22235e51edd83867b64f255eb66db0b5f35d03d26cebc72f535e41e494a3e0ced9dfa99f7ddc8c0b84922ec590266d746ba9bfd53d5a82777
6
+ metadata.gz: af183442e79790255ef4f9b5703b2bf331f3a13ac9e459a63594dc8d11c67b82dab9746c81d2936f2ac7bbd91f802c2ffc9daa3696edce0272def174c940074d
7
+ data.tar.gz: d166c4af0f2e0a98366ad5e52e173a84a500d5390da7047878a7fc4b8f62762eb43fab7589af37b844219588c83c853c0d2d1b8ade1500e6afa14fe7fb9092a0
@@ -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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: subdl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrea Francia