Class: Serienrenamer::Plugin::Textfile
- Inherits:
-
Serienrenamer::Pluginbase
- Object
- Serienrenamer::Pluginbase
- Serienrenamer::Plugin::Textfile
- Defined in:
- lib/serienrenamer/plugin/textfile.rb
Class Method Summary collapse
-
.generate_episode_information(episode) ⇒ Object
this method will be called from the main program with an Serienrenamer::Episode instance or a path to to a directory as parameter.
- .plugin_name ⇒ Object
- .priority ⇒ Object
- .usable ⇒ Object
Methods inherited from Serienrenamer::Pluginbase
inherited, inspect, to_s, type
Class Method Details
.generate_episode_information(episode) ⇒ Object
this method will be called from the main program with an Serienrenamer::Episode instance or a path to to a directory as parameter
it returns an array of episode information
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/serienrenamer/plugin/textfile.rb', line 22 def self.generate_episode_information(episode) sourcedir = "" if episode.is_a?(Serienrenamer::Episode) && episode.source_directory sourcedir = episode.source_directory elsif episode.is_a?(String) && File.directory?(episode) sourcedir = episode end matched_episodes = [] if sourcedir != "" && Dir.exists?(sourcedir) # search for files that are smaller than 128 Bytes # an check if they contain episode information Dir.new(sourcedir).each do |e| file = File.join(sourcedir, e) next if File.size(file) > 128 || File.zero?(file) data = File.open(file, "rb").read # only files with one line with the title are interesting next if data.lines.to_a.size > 1 if data != nil && data.match(/\w+/) && Serienrenamer::Episode.contains_episode_information?(data) matched_episodes.push(data) end end end return matched_episodes end |
.plugin_name ⇒ Object
13 |
# File 'lib/serienrenamer/plugin/textfile.rb', line 13 def self.plugin_name; "Textfile" end |
.priority ⇒ Object
15 |
# File 'lib/serienrenamer/plugin/textfile.rb', line 15 def self.priority; 100 end |
.usable ⇒ Object
14 |
# File 'lib/serienrenamer/plugin/textfile.rb', line 14 def self.usable; true end |