Can a .my file be incorporated? (conversion script included)

Jan 20, 2009 at 8:02 PM
Edited Jan 20, 2009 at 8:04 PM
I tried to post this before, but it never posted. I really like your program and use it to get the metadata and rename my files. It would be a real treat if in your program you could choose a file format to save the metadata in (.xml, .my, etc..), or if your program could save a .my file in addition to an .xml file \I have included a rudimentary script at the bottom of this post. Feel free to use any  or all of it.

The .my file has to have the same name as the media file like so, similar to .xml file:
Two And A Half Men.06x08.Pinocchio's.Mouth.avi
Two And A Half Men.06x08.Pinocchio's.Mouth.my

The content of the .my file would look like this, and can be extracted from the .xml file:

Title=Two And A Half Men
overview=Charlie is a well-to-do bachelor with a house at the beach, a Jaguar in front of the house and an easy way with women. His casual Malibu lifestyle is interrupted when his tightly wound brother, Alan who's facing a divorce, and Alan's son, Jake come to stay with him. Together, these two and a half men confront the challenges of growing up; finally. Complicating matters are the brothers' self-obsessed, controlling mother, Evelyn, Alan's estranged wife, Judith and Charlie's crazy neighbour Rose. who wants to be a part of his life and is willing to do anything to be around.
TVOriginalAiringDate=2008-11-17
actors=Charlie Sheen, Jon Cryer, Angus T. Jones, April Bowlby, Conchata Ferrell, Marin Hinkle, Holland Taylor, Melanie Lynskey,
TVEpisode=Pinocchio's Mouth
TVOverview=A new girlfriend wants Charlie to sleep over. Meanwhile, Alan has trouble making a punishment stick to Jake.
TVDuration=30 minutes
TVGenre=Comedy
TVChannelName=CBS

Naturally, not all of the information can be had from the xml file, but as much as possible would be best.

This is my first attempt at scripting in Ruby, so please excuse my novice approach.
This Ruby script will extract XML data elements from from metadata folder and create a .my file for use in SAGETV.
Open notepad, copy script and paste it in notepad, save notepad as "whatever".rb
Run script one level up from metadata folder to extract the xml data elements and create a new .my file.

**********Begin Script**********
require 'rexml/document'
require 'pathname'
require 'find'

include REXML

Dir.new('.').entries.reject {|f| [".", ".."].include? f}

#Set Current Directory
dirs = ["."] #["Y:/TV"]

#Set folder name containing xml files to be processed.
excludes = ["metadata"]

#Loop through directory and set path to metadata directory.
for dir in dirs
  Find.find(dir) do |path|
    #Is the metadata folder a directory?
    if FileTest.directory?(path)
      #Check the path against the excludes variable above?
      if excludes.include?(File.basename(path))
        #Iterate through files in path directory
        Dir.new(base_dir = (path) + "/").each do |filename|
          unless ['.', '..'].include? filename
          #Check if file is an XML file, those are the ones to process.
          if File.extname(filename) == '.xml'
            
            #Set the file variable to the full path & filename
            file = "#{path}"+'/'+"#{filename}"
            
            #Add a / to the end of the path
            path2 = (path)+"/"
            
            #Strip the file extention .xml and convert to string
            path3 = path2 + File.basename(filename,".xml") .to_s
            
            #Set name of new .my file
            #file3 = File.basename(path3) + ".my"
            file3 = path2 + File.basename(filename,".xml") + ".my"
            file4 =  file3.to_s
            puts file4
            
            #Set the variable for use below fir writing out xml elements
            file = File.new(file)
            doc = Document.new(file)
            root = doc.root
            
            # Create a new file and write to it  
            File.open(file4 , 'w') do |f2|  
                 # use "\n" for two lines of text  
                root.elements.each("FirstAired")  { |element| f2.puts "TVOriginalAiringDate=" +element.text }
                root.elements.each("EpisodeName")  { |element| f2.puts "TVEpisode=" +element.text }
                root.elements.each("Overview")  { |element| f2.puts "overview=" +element.text }
              end
              end  
          end
        end


      end
    else
      #p path
    end
  end
end

#root = doc.root
#puts root.elements["EpisodeName"]
**********End Script**********
Coordinator
Jan 20, 2009 at 8:06 PM
Thanks for the info, I actually did get your request from my blog site, and have entered an issue report regarding it with one of the features.

I will be more than happy to add something like that for you.

Here is the bug ticket: http://www.codeplex.com/tvmetadatafinder/WorkItem/View.aspx?WorkItemId=417

I will be working on it sometime, and keep an eye open for the changes.

Bill.
Jan 20, 2009 at 8:16 PM
Wow, thanks Bill. I was not expecting such a fast response.
I will use the RSS feed from the project site to keep up to date on the changes.
R00st3r
Coordinator
Jan 21, 2009 at 5:22 AM
Compleated:

Can you try out this planned release?: http://www.codeplex.com/tvmetadatafinder/Release/ProjectReleases.aspx?ReleaseId=22104

Title=Two and a Half Men
overview=Charlie is a well-to-do bachelor with a house at the beach, a Jaguar in front of the house and an easy way with women. His casual Malibu lifestyle is interrupted when his tightly wound brother, Alan who's facing a divorce, and Alan's son, Jake come to stay with him. Together, these two and a half men confront the challenges of growing up; finally. Complicating matters are the brothers' self-obsessed, controlling mother, Evelyn, Alan's estranged wife, Judith and Charlie's crazy neighbour Rose. who wants to be a part of his life and is willing to do anything to be around.
TVOriginalAiringDate=2008-09-22
actors=Charlie Sheen, Jon Cryer, Angus T. Jones, April Bowlby, Conchata Ferrell, Marin Hinkle, Holland Taylor, Melanie Lynskey
TVEpisode=1
TVOverview=In the Sixth Season opener, Charlie runs into an Ex-girlfriend( Rena Sofer) and a child who bears a striking resemblance to Charlie.
TVDuration=30
TVGenre=Comedy
TVChannelName=CBS
Coordinator
Jan 23, 2009 at 1:50 AM
Have you been able to try this out yet?    
Jan 23, 2009 at 1:09 PM
Edited Jan 23, 2009 at 1:13 PM
I tried it out, but did not see an option for .my files.
I ran it against a directory that had a new .avi file and it renamed it and created a .xml file in the metadata folder, but no.my file.
Does it create a .xml and .my file by default or is there an actual option that needs to be turned on?

I don't really see a change in the program
I downloaded it twice just to be sure.

Please Advise.
 
Also I checked the product version in both the app 9about page) and proerties and they both say 1.7.2.0 not 1.7.2.0c..should it?

Thanks!
Coordinator
Jan 23, 2009 at 1:37 PM
Thanks, I know there was some confusion with the diffrent versions....  I had to roll back some stuff, and come to think of it may be it is missing out of this release...  Once i get home this weekend, i will check it out.

Bill.
Coordinator
Jan 27, 2009 at 3:55 AM
Hey, sorry about the wait... Give it a shot now: http://www.codeplex.com/tvmetadatafinder/Release/ProjectReleases.aspx?ReleaseId=22316


Bill.
Jan 27, 2009 at 6:13 AM
Bill,

Thanks for the update. It seems to work fine. It saves the .my file in the same directory as the .avi, which is where it needs to be.
It didn't work at first as I only checked "save .my file" and not "Save Metadata" as well. Once I checked "Save Metadata" it worked fine.
Thanks again.

Coordinator
Jan 27, 2009 at 1:02 PM
I found an issue with the monitoring, i fixed it, it wasnt renaming the files right.  Try it again: http://www.codeplex.com/tvmetadatafinder/Release/ProjectReleases.aspx?ReleaseId=22346