mediaman 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/mediaman/document.rb +2 -2
- data/lib/mediaman/media_filename.rb +10 -4
- data/lib/mediaman/trakt.rb +3 -3
- data/lib/mediaman/version.rb +1 -1
- data/spec/mediaman/media_filename_spec.rb +24 -4
- metadata +1 -1
data/lib/mediaman/document.rb
CHANGED
@@ -98,9 +98,9 @@ module Mediaman
|
|
98
98
|
def remote_metadata
|
99
99
|
@remote_metadata ||= begin
|
100
100
|
if local_metadata['movie']
|
101
|
-
Metadata.new({'movie_details' => Trakt::Movie.new(title: local_metadata['name'], year: local_metadata['year'])})
|
101
|
+
Metadata.new({'movie_details' => Trakt::Movie.new(title: local_metadata['name'], year: local_metadata['year'], title_slug: local_metadata['title_slug'])})
|
102
102
|
elsif local_metadata['tv']
|
103
|
-
tv = Trakt::TVEpisode.new show_title: local_metadata['name'], season_number: local_metadata['season_number'], episode_number: local_metadata['episode_number']
|
103
|
+
tv = Trakt::TVEpisode.new show_title: local_metadata['name'], season_number: local_metadata['season_number'], episode_number: local_metadata['episode_number'], title_slug: local_metadata['title_slug']
|
104
104
|
Metadata.new({'episode_details' => tv.to_hash, 'show_details' => tv.show.to_hash})
|
105
105
|
end
|
106
106
|
rescue
|
@@ -7,10 +7,15 @@ module Mediaman
|
|
7
7
|
attr_accessor :filename
|
8
8
|
|
9
9
|
def initialize(filename)
|
10
|
-
self.filename = filename
|
10
|
+
self.filename = override_filename filename
|
11
11
|
@parsed_name = self.to_name
|
12
12
|
end
|
13
13
|
|
14
|
+
def override_filename(name)
|
15
|
+
name.gsub!("2012", "") if name.include?("Newsroom")
|
16
|
+
name
|
17
|
+
end
|
18
|
+
|
14
19
|
def to_name
|
15
20
|
fn = ToName.to_name(filename)
|
16
21
|
{
|
@@ -34,7 +39,8 @@ module Mediaman
|
|
34
39
|
season_number: self.season,
|
35
40
|
episode_number: self.episode,
|
36
41
|
hd: self.hd?,
|
37
|
-
hd_format: self.hd_format
|
42
|
+
hd_format: self.hd_format,
|
43
|
+
title_slug: self.title_slug
|
38
44
|
}
|
39
45
|
end
|
40
46
|
|
@@ -46,9 +52,9 @@ module Mediaman
|
|
46
52
|
name = @parsed_name[:name]
|
47
53
|
|
48
54
|
# Hacks
|
49
|
-
name.gsub! /Extended( Version)( Edition)
|
55
|
+
name.gsub! /Extended( Version)?( Edition)?/i, ""
|
50
56
|
|
51
|
-
name
|
57
|
+
name.strip.chomp
|
52
58
|
end
|
53
59
|
|
54
60
|
def title_slug
|
data/lib/mediaman/trakt.rb
CHANGED
@@ -56,11 +56,11 @@ module Mediaman
|
|
56
56
|
end
|
57
57
|
|
58
58
|
def slug
|
59
|
-
options[:slug].presence || "#{
|
59
|
+
options[:slug].presence || "#{title_slug}/#{options[:season_number]}/#{options[:episode_number]}"
|
60
60
|
end
|
61
61
|
|
62
|
-
def
|
63
|
-
options[:
|
62
|
+
def title_slug
|
63
|
+
options[:title_slug].presence || "#{options[:show_title].parameterize}"
|
64
64
|
end
|
65
65
|
|
66
66
|
end
|
data/lib/mediaman/version.rb
CHANGED
@@ -44,19 +44,39 @@ describe Mediaman::MediaFilename do
|
|
44
44
|
h[:episode_number].should == 3
|
45
45
|
end
|
46
46
|
|
47
|
+
it "My Best Friend 6x03" do
|
48
|
+
h = parse("My Best Friend 6x03")
|
49
|
+
h[:name].should == "My Best Friend"
|
50
|
+
h[:season_number].should == 6
|
51
|
+
h[:episode_number].should == 3
|
52
|
+
end
|
53
|
+
|
47
54
|
it "extended editions" do
|
48
55
|
h = parse("The Fall Extended Edition")
|
49
56
|
h[:name].should == "The Fall"
|
50
57
|
end
|
51
58
|
|
52
|
-
it "extended
|
59
|
+
it "extended version" do
|
53
60
|
h = parse("The Fall Extended Version")
|
54
61
|
h[:name].should == "The Fall"
|
55
62
|
end
|
56
63
|
|
57
|
-
it "
|
58
|
-
h = parse("The
|
59
|
-
h[:
|
64
|
+
it "Newsroom 2012" do
|
65
|
+
h = parse("The Newsroom 2012 S01E01")
|
66
|
+
h[:tv].should be_true
|
67
|
+
h[:name].should == "The Newsroom"
|
68
|
+
h[:title_slug].should == "the-newsroom-2012"
|
69
|
+
h[:season_number].should == 1
|
70
|
+
h[:episode_number].should == 1
|
71
|
+
end
|
72
|
+
|
73
|
+
it "Newsroom 2012" do
|
74
|
+
h = parse("The Newsroom S01E01")
|
75
|
+
h[:tv].should be_true
|
76
|
+
h[:name].should == "The Newsroom"
|
77
|
+
h[:title_slug].should == "the-newsroom-2012"
|
78
|
+
h[:season_number].should == 1
|
79
|
+
h[:episode_number].should == 1
|
60
80
|
end
|
61
81
|
|
62
82
|
end
|