sjunkieex 0.0.4 → 0.1.0

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.
@@ -1,12 +1,13 @@
1
1
  # encoding: UTF-8
2
2
  require File.dirname(__FILE__) + '/test_helper.rb'
3
+ require 'sindex'
3
4
 
4
5
  class TestInterface < Test::Unit::TestCase
5
6
 
6
7
  def setup
7
- files = [ File.dirname(__FILE__) + '/seriesindex_example.xml' ]
8
+ file = File.dirname(__FILE__) + '/seriesindex_example.xml'
8
9
 
9
- @series_index = Sjunkieex::SeriesIndex.new(files: files)
10
+ @series_index = Sindex::SeriesIndex.new(index_file: file)
10
11
  end
11
12
 
12
13
 
@@ -36,10 +37,10 @@ class TestInterface < Test::Unit::TestCase
36
37
  assert_equal false, links.empty?
37
38
 
38
39
  assert_equal true, links.include?("http://serienjunkies.org/serie/chase-2010/")
39
- assert_equal "chase", links["http://serienjunkies.org/serie/chase-2010/"]
40
+ assert_equal "Chase", links["http://serienjunkies.org/serie/chase-2010/"]
40
41
 
41
42
  assert_equal true, links.include?("http://serienjunkies.org/serie/shameless-us/")
42
- assert_equal "shameless us", links["http://serienjunkies.org/serie/shameless-us/"]
43
+ assert_equal "Shameless US", links["http://serienjunkies.org/serie/shameless-us/"]
43
44
  end
44
45
 
45
46
  def test_parse_homepage_with_range
@@ -51,7 +52,7 @@ class TestInterface < Test::Unit::TestCase
51
52
  assert_equal false, links.empty?
52
53
 
53
54
  assert_equal true, links.include?("http://serienjunkies.org/serie/white-collar/")
54
- assert_equal "white collar", links["http://serienjunkies.org/serie/white-collar/"]
55
+ assert_equal "White Collar", links["http://serienjunkies.org/serie/white-collar/"]
55
56
  end
56
57
 
57
58
  def test_parse_chase_series_page
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sjunkieex
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-09-28 00:00:00.000000000 Z
12
+ date: 2012-10-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri
@@ -43,6 +43,22 @@ dependencies:
43
43
  - - ! '>='
44
44
  - !ruby/object:Gem::Version
45
45
  version: 0.0.1
46
+ - !ruby/object:Gem::Dependency
47
+ name: sindex
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: 0.1.0
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: 0.1.0
46
62
  description: Tool that extracts links from serienjunkies.org
47
63
  email:
48
64
  - philipp@i77i.de
@@ -52,6 +68,7 @@ extensions: []
52
68
  extra_rdoc_files: []
53
69
  files:
54
70
  - .gitignore
71
+ - .travis.yml
55
72
  - Gemfile
56
73
  - LICENSE
57
74
  - README.md
@@ -59,7 +76,6 @@ files:
59
76
  - bin/sjunkieex
60
77
  - lib/sjunkieex.rb
61
78
  - lib/sjunkieex/interface.rb
62
- - lib/sjunkieex/series_index.rb
63
79
  - lib/sjunkieex/version.rb
64
80
  - sjunkieex.gemspec
65
81
  - test/seriesindex_example.xml
@@ -69,7 +85,6 @@ files:
69
85
  - test/site_dumps/rizzoli_and_isles.html
70
86
  - test/test_helper.rb
71
87
  - test/test_interface.rb
72
- - test/test_series_index.rb
73
88
  homepage: ''
74
89
  licenses: []
75
90
  post_install_message:
@@ -82,12 +97,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
82
97
  - - ! '>='
83
98
  - !ruby/object:Gem::Version
84
99
  version: '0'
100
+ segments:
101
+ - 0
102
+ hash: 1994197652056576143
85
103
  required_rubygems_version: !ruby/object:Gem::Requirement
86
104
  none: false
87
105
  requirements:
88
106
  - - ! '>='
89
107
  - !ruby/object:Gem::Version
90
108
  version: '0'
109
+ segments:
110
+ - 0
111
+ hash: 1994197652056576143
91
112
  requirements: []
92
113
  rubyforge_project:
93
114
  rubygems_version: 1.8.24
@@ -102,5 +123,3 @@ test_files:
102
123
  - test/site_dumps/rizzoli_and_isles.html
103
124
  - test/test_helper.rb
104
125
  - test/test_interface.rb
105
- - test/test_series_index.rb
106
- has_rdoc:
@@ -1,138 +0,0 @@
1
- require 'nokogiri'
2
-
3
- module Sjunkieex
4
-
5
- class SeriesIndex
6
-
7
- attr_reader :options, :series_data
8
-
9
- # Public: instantiate a new series_index
10
- #
11
- # options - Options (default: {})
12
- # :files - Array of series indizes
13
- #
14
- def initialize(options = {})
15
- @options = {files: [], }.merge(options)
16
-
17
- @series_data = Hash.new
18
- @options[:files].each do |file|
19
- @series_data.merge!(parse_file(file))
20
- end
21
-
22
- end
23
-
24
- # Public: checks if there are entries in the index
25
- #
26
- # Returns true if there no entries loaded
27
- def empty?
28
- @series_data.length == 0
29
- end
30
-
31
- # Public: Check if a supplied episode is in the index
32
- #
33
- # series_name - Name of the series in the index
34
- # episode_text - episode data
35
- #
36
- # Returns true if the episode is existing, false otherwise
37
- def episode_existing?(series_name, episode_text)
38
- series_name.downcase!
39
-
40
- if @series_data[series_name]
41
-
42
- if id = SeriesIndex.extract_episode_identifier(episode_text)
43
- if @series_data[series_name][id]
44
- return true
45
- end
46
- end
47
- end
48
-
49
- return false
50
- end
51
-
52
- # Public: checks if the seriesname in the supplied data is in the index
53
- #
54
- # episode_text - data that contains the episode information
55
- #
56
- # Returns true if the series is in the index, false otherwise
57
- def is_series_in_index?(episode_text)
58
-
59
- if series_name = SeriesIndex.extract_seriesname(episode_text)
60
- if @series_data[series_name.downcase]
61
- return true
62
- end
63
- end
64
-
65
- return false
66
- end
67
-
68
- # Public: tries to extract the seriesname from supplied data
69
- #
70
- # data - data that holds the episode information
71
- #
72
- # Returns the seriesname or nil if there is no seriesname
73
- def self.extract_seriesname(data)
74
- if md = data.match(/(.+?)S\d+E\d+/)
75
- return md[1].gsub(/\./, " ").strip
76
- end
77
- nil
78
- end
79
-
80
- # Public: tries to extract the episode identifier from the episode data
81
- #
82
- # data - data that holds the episode information
83
- #
84
- # Returns the identifier xx_xx or nil if there is no identifier
85
- def self.extract_episode_identifier(data)
86
- if md = data.match(/S(\d+)E(\d+)/i)
87
- return "%s_%s" % [md[1].to_i, md[2].to_i]
88
- end
89
- nil
90
- end
91
-
92
- private
93
-
94
- # Internal: parse this file to a hash indexed by seriesname
95
- #
96
- # file - path to the xml file
97
- #
98
- # Returns a Hash indexed by seriesname with Hashes as values
99
- #
100
- # hash = {
101
- # "Chase": {
102
- # "1_1": "S01E01 - test.avi",
103
- # }
104
- # }
105
- def parse_file(file)
106
-
107
- series_data = Hash.new
108
-
109
- content = File.open(file, "r").read
110
- doc = Nokogiri::XML(content)
111
-
112
- doc.css("serienindex > directory").each do |series_node|
113
-
114
- title = series_node[:name]
115
- next unless title && title.match(/\w+/)
116
-
117
- title.downcase!
118
-
119
- series = Hash.new
120
- series_node.css("file").each do |file_node|
121
-
122
- filename = file_node[:name]
123
- next unless filename
124
-
125
- if id = SeriesIndex.extract_episode_identifier(filename)
126
- series[id] = filename
127
- end
128
- end
129
-
130
- series_data[title] = series
131
- end
132
-
133
- series_data
134
- end
135
-
136
- end
137
-
138
- end
@@ -1,74 +0,0 @@
1
- # encoding: UTF-8
2
- require File.dirname(__FILE__) + '/test_helper.rb'
3
-
4
- class TestInterface < Test::Unit::TestCase
5
-
6
- def setup
7
- files = [ File.dirname(__FILE__) + '/seriesindex_example.xml' ]
8
-
9
- @series_index = Sjunkieex::SeriesIndex.new(files: files)
10
- end
11
-
12
- def test_instantiating
13
- index = Sjunkieex::SeriesIndex.new()
14
- assert_instance_of Sjunkieex::SeriesIndex, index
15
- end
16
-
17
- def test_parse_seriesindex
18
- assert_equal 13, @series_index.series_data["chase"].length
19
-
20
- assert_equal "S01E04 - Blutiger Wahnsinn.avi",
21
- @series_index.series_data["chase"]["1_4"]
22
-
23
- assert_equal false, @series_index.empty?
24
- end
25
-
26
- def test_check_for_episode_existance
27
- assert_equal true, @series_index.episode_existing?("Chase",
28
- "Chase.S01E04.Episodename.avi")
29
-
30
- assert_equal false, @series_index.episode_existing?("Chase",
31
- "Chase.S03E04.Episodename.avi")
32
-
33
- assert_equal true, @series_index.episode_existing?("Miami Medical",
34
- "Miami.Medical.S01E04.Episodename.avi")
35
-
36
- assert_equal false, @series_index.episode_existing?("Not Exisiting",
37
- "Not.Existing.S03E04.Episodename.avi")
38
-
39
- assert_equal false, @series_index.episode_existing?("Chase",
40
- "Chase.S01E14.Rache.an.Annie.Teil.3.GERMAN.DUBBED.DL.720p.HDTV.x264-TVP")
41
-
42
- assert_equal true, @series_index.episode_existing?("Shameless US",
43
- "Shameless.US.S02E11.Just.Like.The.Pilgrims.Intended.German.Dubbed.DL.VoDHD.XviD-TVS")
44
-
45
- assert_equal true, @series_index.episode_existing?("The Listener",
46
- "The.Listener.S03E01.Bankgeheimnis.DL.German.HDTV.XviD-GDR")
47
- end
48
-
49
- def test_check_seriesname_in_index
50
- assert_equal true, @series_index.is_series_in_index?(
51
- "Chase.S01E13.Rache.an.Annie.Teil.2.GERMAN.DUBBED.WS.HDTVRip.XviD-TVP")
52
-
53
- assert_equal true, @series_index.is_series_in_index?(
54
- "Unforgettable.S01E08.All.unsere.Sachen.German.DL.Dubbed.WS.WEB-DL.XviD.REPACK-GDR")
55
-
56
- assert_equal true, @series_index.is_series_in_index?(
57
- "Life.Unexpected.S02E10.Spiel.mit.dem.Feuer.German.Dubbed.DL.720p.WEB-DL.h264-GDR")
58
-
59
- assert_equal false, @series_index.is_series_in_index?(
60
- "Ugly.Betty.S03E10.Boese.Amanda.German.DL.Dubbed.WEBRiP.XViD-GDR")
61
-
62
- assert_equal false, @series_index.is_series_in_index?(
63
- "Memphis.Beat.S01E06.Sein.letzter.Kampf.GERMAN.DUBBED.720p.HDTV.x264-ZZGtv")
64
-
65
- assert_equal false, @series_index.is_series_in_index?(
66
- "Private.Practice.S05E12.Aussichtsloser.Kampf.German.Dubbed.WS.WEB-DL.XviD-GDR")
67
- end
68
-
69
- def test_check_seriesname_in_index_case_insensitive
70
- assert_equal true, @series_index.is_series_in_index?(
71
- "Two.and.a.half.Men.S09E09.Ein.Opossum.auf.Chemo.German.Dubbed.WS.WEB-DL.XviD-GDR")
72
-
73
- end
74
- end