Class: XbmcSql::NfoFile
- Inherits:
-
Object
- Object
- XbmcSql::NfoFile
- Defined in:
- lib/xbmc_sql/nfo_file.rb
Constant Summary collapse
- SIMPLE_ATTRIBUTES =
%w{ id title originaltitle sorttitle year releasedate top250 rating votes mpaa certification studio outline plot runtime playcount }- PLURAL_ATTRIBUTES =
{ countries: 'country', genres: 'genre', directors: 'director', credits: 'credits', actors: 'actor', thumbs: 'thumb', fanart: 'fanart' }
Instance Attribute Summary collapse
-
#raw_file ⇒ Object
Returns the value of attribute raw_file.
Instance Method Summary collapse
- #audio_streams ⇒ Object
- #doc ⇒ Object
-
#initialize(raw_file) ⇒ NfoFile
constructor
A new instance of NfoFile.
- #new_doc ⇒ Object
- #save! ⇒ Object
- #sub_streams ⇒ Object
- #video_stream ⇒ Object
-
#video_streams ⇒ Object
File info.
Constructor Details
#initialize(raw_file) ⇒ NfoFile
Returns a new instance of NfoFile.
7 8 9 |
# File 'lib/xbmc_sql/nfo_file.rb', line 7 def initialize(raw_file) @raw_file = raw_file end |
Instance Attribute Details
#raw_file ⇒ Object
Returns the value of attribute raw_file.
5 6 7 |
# File 'lib/xbmc_sql/nfo_file.rb', line 5 def raw_file @raw_file end |
Instance Method Details
#audio_streams ⇒ Object
59 60 61 |
# File 'lib/xbmc_sql/nfo_file.rb', line 59 def audio_streams streams['audio'] end |
#doc ⇒ Object
15 16 17 |
# File 'lib/xbmc_sql/nfo_file.rb', line 15 def doc @doc ||= XmlSimple.xml_in(File.read(@raw_file)) end |
#new_doc ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/xbmc_sql/nfo_file.rb', line 19 def new_doc out = XmlSimple.xml_out doc, xmldeclaration: '<?xml version="1.0" encoding="utf-8"?>', rootname: 'movie', noescape: true out.gsub /<([^>]+)>\s*<\/\1>/, '<\1 />' end |
#save! ⇒ Object
11 12 13 |
# File 'lib/xbmc_sql/nfo_file.rb', line 11 def save! File.open(raw_file, 'w+') { |f| f.write new_doc } end |
#sub_streams ⇒ Object
63 64 65 |
# File 'lib/xbmc_sql/nfo_file.rb', line 63 def sub_streams streams['sub'] end |
#video_stream ⇒ Object
67 68 69 |
# File 'lib/xbmc_sql/nfo_file.rb', line 67 def video_stream video_streams[0] end |
#video_streams ⇒ Object
File info
55 56 57 |
# File 'lib/xbmc_sql/nfo_file.rb', line 55 def video_streams streams['video'] end |