subtitulos_downloader 0.6.0 → 0.6.1
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.
@@ -57,31 +57,37 @@ module SubtitulosDownloader
|
|
57
57
|
|
58
58
|
def get_subtitles(language, episode_table, show_sub)
|
59
59
|
@provider_link = (episode_table/"td.NewsTitle/a").first.attributes['href']
|
60
|
+
translation_unfinished = false
|
60
61
|
(episode_table/"tr/td.language").each do |lang|
|
61
62
|
language_sub = lang.inner_html.strip.force_encoding('utf-8')
|
62
63
|
if language_sub =~ /#{language}/i
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
64
|
+
# puts "Language #{language} found"
|
65
|
+
if not lang.next_sibling.inner_html =~ /[0-9]+\.?[0-9]*% Completado/i
|
66
|
+
# puts "Translation for language #{language} completed"
|
67
|
+
subtitle_a = lang.parent.search("a").at(0)
|
68
|
+
subtitle_url = subtitle_a.attributes['href']
|
69
|
+
# puts "Fetching #{language} subtitle file"
|
70
|
+
@provider_language = language_sub
|
71
|
+
@direct_link = subtitle_url
|
72
|
+
# @provider_link = "#{@base_uri}/show/#{show_sub[:id_show]}"
|
73
|
+
translation_unfinished = false
|
74
|
+
open(subtitle_url,
|
75
|
+
"User-Agent" => @user_agent,
|
76
|
+
"Referer" => "#{@base_uri}/show/#{show_sub[:id_show]}") { |f|
|
77
|
+
# Save the response body
|
78
|
+
subs= f.read
|
79
|
+
return subs
|
80
|
+
}
|
81
|
+
else
|
82
|
+
translation_unfinished = true
|
83
|
+
end
|
82
84
|
end
|
83
85
|
end
|
84
|
-
|
86
|
+
if translation_unfinished
|
87
|
+
raise TranslationNotFinished, "[#{@provider_name}] #{language} translation not finished for #{show_sub[:show_episode].full_name}"
|
88
|
+
else
|
89
|
+
raise LanguageNotFound, "[#{@provider_name}] #{language} not found for #{show_sub[:show_episode].full_name}"
|
90
|
+
end
|
85
91
|
end
|
86
92
|
|
87
93
|
|
@@ -98,6 +104,7 @@ module SubtitulosDownloader
|
|
98
104
|
show_url = show_subs.attributes['href']
|
99
105
|
show = { :show_episode => show_episode, :url => show_url, :id_show => show_url.split('/show/')[1].to_i }
|
100
106
|
if (show_name == show_episode.show_name)
|
107
|
+
shows = []
|
101
108
|
shows << show
|
102
109
|
break
|
103
110
|
elsif show_name =~ /^#{show_episode.show_name}/i and (show_name != 'Scrubs Interns' and show_name != 'true blood minisodes')
|
data/spec/show_episode_spec.rb
CHANGED
@@ -33,7 +33,7 @@ describe SubtitulosDownloader::ShowEpisode do
|
|
33
33
|
|
34
34
|
it 'should show the subtitle given a language' do
|
35
35
|
episode = SubtitulosDownloader::ShowEpisode.new('fake show', 3, 3)
|
36
|
-
subtitle = SubtitulosDownloader::Subtitle.new('subs', 'es', episode,
|
36
|
+
subtitle = SubtitulosDownloader::Subtitle.new('subs', 'es', episode, 'direct_link', 'provider_link', 'provider', 'provider_language')
|
37
37
|
sub = episode.subtitle_language 'es'
|
38
38
|
sub.should == subtitle
|
39
39
|
sub.subtitles.should =='subs'
|
data/spec/subtitulos_es_spec.rb
CHANGED
@@ -52,6 +52,14 @@ describe SubtitulosDownloader::SubtitulosEs do
|
|
52
52
|
subs = (subtitle.subtitles =~ /Quello che conta e' che sono nei guai./) > 1
|
53
53
|
subs.should == true
|
54
54
|
end
|
55
|
+
|
56
|
+
it 'should fetch second español if first is not completed' do
|
57
|
+
episode = SubtitulosDownloader::ShowEpisode.new('Hustle', 7, 3)
|
58
|
+
subtitle = @provider.fetch(episode, 'es')
|
59
|
+
subtitle.language.should == 'es'
|
60
|
+
subtitle.show_episode.should == episode
|
61
|
+
subs = (subtitle.subtitles =~ /el reverendo R.G. Wendell/) > 1
|
62
|
+
end
|
55
63
|
end
|
56
64
|
|
57
65
|
context "Rasing Exceptions" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: subtitulos_downloader
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -115,7 +115,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
115
115
|
version: '0'
|
116
116
|
segments:
|
117
117
|
- 0
|
118
|
-
hash:
|
118
|
+
hash: 2243448483779133464
|
119
119
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
120
120
|
none: false
|
121
121
|
requirements:
|
@@ -124,7 +124,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
124
124
|
version: '0'
|
125
125
|
segments:
|
126
126
|
- 0
|
127
|
-
hash:
|
127
|
+
hash: 2243448483779133464
|
128
128
|
requirements: []
|
129
129
|
rubyforge_project: subtitulos_downloader
|
130
130
|
rubygems_version: 1.8.24
|