class Blitzcrank::Video
Constants
- MOVIE_REGEX
- TV_SHOW_REGEX
Public Class Methods
file_name(file_path)
click to toggle source
# File lib/blitzcrank/video.rb, line 18 def self.file_name(file_path) file_path.split('/').last end
is_movie?(file_name)
click to toggle source
movie methods
# File lib/blitzcrank/video.rb, line 28 def self.is_movie?(file_name) if Video.is_tv_show?(file_name) return false elsif MOVIE_REGEX.match(file_name).nil? == false movie_name = $1 nice_movie_name = movie_name.gsub('.', ' ').downcase i = Imdb::Search.new(nice_movie_name) i.movies.size > 0 else false end end
is_tv_show?(file_name)
click to toggle source
returns if this is a TV show or not
# File lib/blitzcrank/video.rb, line 23 def self.is_tv_show?(file_name) TV_SHOW_REGEX.match(file_name).nil? == false end
new(file_path)
click to toggle source
# File lib/blitzcrank/video.rb, line 41 def initialize(file_path) @file_path = file_path @file_name = Video.file_name file_path end
with_path(file_path)
click to toggle source
# File lib/blitzcrank/video.rb, line 8 def self.with_path(file_path) file_name = Video.file_name(file_path) if Video.is_tv_show? file_name return TVShow.new file_path elsif Video.is_movie? file_name return Movie.new file_path end return Video.new file_path end
Public Instance Methods
file_name()
click to toggle source
# File lib/blitzcrank/video.rb, line 50 def file_name @file_name end
is_movie?()
click to toggle source
movie methods
# File lib/blitzcrank/video.rb, line 75 def is_movie? Video.is_movie?(@file_name) end
is_tv_show?()
click to toggle source
returns if this is a TV show or not
# File lib/blitzcrank/video.rb, line 70 def is_tv_show? Video.is_tv_show?(@file_name) end
nice_name()
click to toggle source
# File lib/blitzcrank/video.rb, line 54 def nice_name unless TV_SHOW_REGEX.match(@file_name).nil? showName = $1 wordsInShowName = showName.gsub(/[\._]/, ' ').downcase.split(" ") # strip . and _ wordsInShowName.each do |word| if wordsInShowName.index(word) == 0 || /^(in|a|the|and|on)$/i.match(word).nil? word.capitalize! end end wordsInShowName.join(" ").gsub(/\b(us|uk|\d{4})$/i, '(\1)') # adding parens around US/UK marked shows, or shows with years else @file_name end end
remote_path()
click to toggle source
# File lib/blitzcrank/video.rb, line 46 def remote_path @file_path end