Suggestion

If you made a script you can offer it to the others here, or ask help to improve it. You can also report here bugs & problems with existing scripts.
Post Reply
Nicezia
Posts: 14
Joined: 2008-10-17 04:41:01

Suggestion

Post by Nicezia »

I am using XBMC as my Video Player, as most of my Movies are archived on external harddrives. Is it possible to make an export individual movies to XML format that XBMC can use?

The XML structure is pretty easy for XBMC

as i can outline ith here

Code: Select all

<movie>
        <title>Who knows</title>
        <originaltitle>Who knows for real</originaltitle>
        <rating>6.100000</rating>
        <year>2008</year>
        <top250>0</top250>
        <votes>50</votes>
        <outline>A look at the role of the Buckeye State in the 2004 Presidential Election.</outline>
        <plot>A look at the role of the Buckeye State in the 2004 Presidential Election.</plot>
        <tagline></tagline>
        <runtime>90 min</runtime>
        <thumb>moviename.jpg</thumb>
        <mpaa>Not available</mpaa>
        <playcount>0</playcount>
        <watched>false</watched>
        <id>tt0432337</id>
        <filenameandpath>c:\Dummy_Movie_Files\Movies\...So Goes The Nation.avi</filenameandpath>
        <trailer></trailer>
        <genre></genre>
        <credits></credits>
        <director>Adam Del Deo</director>
        <actor>
            <name>Paul Begala</name>
            <role>Himself</role>
        </actor>
        <actor>
            <name>George W. Bush</name>
            <role>Himself</role>
        </actor>
        <actor>
            <name>Mary Beth Cahill</name>
            <role>Herself</role>
        </actor>
        <actor>
            <name>Ed Gillespie</name>
            <role>Himself</role>
        </actor>
        <actor>
            <name>John Kerry</name>
            <role>Himself</role>
        </actor>
    </movie>
it seems simple enough.
but that's from a non-coder's perspective.
i looked at the XML export option in AMC already, and the only difference is the tags, and the fact that it exports all the movies to the same XML file while it would be prefferable to myself (and i'm going to have to sound selfish here) if the files could be seperated and you can choose what you wanted to rename tags, so not only could it be useful for XBMC, it pretty much could be used for a universal movie information export.

The only true difficulty in this,that i can see, is parsing the actor field to write the actors out seperately. Because i attempted to do a script to export the file myself, but not knowing how to parse files it made it difficult when i came to trying to seperate the actors individually. Actors in my catalog are usually seperated by a comma or a new line. And i couldn't figure for the life of me, how to make it recognize the seperate Actors for writing out to XML
bad4u
Posts: 1148
Joined: 2006-12-11 22:54:46

Post by bad4u »

Nicezia wrote:... and the fact that it exports all the movies to the same XML file while it would be prefferable to myself (and i'm going to have to sound selfish here) if the files could be seperated ..
You want to export a separate XML file for every film ? This could easily be done using AMC's scripting engine.
..and you can choose what you wanted to rename tags, so not only could it be useful for XBMC, it pretty much could be used for a universal movie information export.
Not posssible (yet). The default "export to XML" is the same as when you use "save as.." from the menu and save your catalog to XML format, it does not use a separated XML export function. It's just default XML catalog format.
The only true difficulty in this,that i can see, is parsing the actor field to write the actors out seperately.
The problem is not to separate the actors in general, this could be done by choosing the list format via option on the script, but it gets a problem if there are different formats on the same catalog (e.g. if various scripts have been used for some movies).
Nicezia
Posts: 14
Joined: 2008-10-17 04:41:01

Post by Nicezia »

You want to export a separate XML file for every film ? This could easily be done using AMC's scripting engine.
That would be good and all, but I know jack about whatever format the scripts are in. If i knew what i was doing in the scripts i probably wouldn't be here asking for this feature... I'm not a programmer, and i honestly have a problem getting my head wrapped around scripting. I tried with minimal success, and there is no "AMC scripting for dummies"
Not posssible (yet). The default "export to XML" is the same as when you use "save as.." from the menu and save your catalog to XML format, it does not use a separated XML export function. It's just default XML catalog format.


I know its not possible YET, but even thinking of it as a non-coder (but someone who has at least tried) there has to be routines that tell the program what to output the XML tags as, and i imagine (though i know nothing of delphi, but the little C,C++,C#, & Visual Basic i have learned says) it would be simple to allow the tags to be defined before output, and the interface for such even i could write in C or Visual Basic, and in fact have, however, have no way to integrate it into AMC since its Delphi. I wanted to try to edit the source code, but i don't know delphi, and it just confused the crapola out of me.
The problem is not to separate the actors in general, this could be done by choosing the list format via option on the script, but it gets a problem if there are different formats on the same catalog (e.g. if various scripts have been used for some movies).
Pretty sure it would be easy via scripting, but again i haven't the slightest clue how to do so, if you could offer some suggestions on how to script what i'm suggesting, then i would like to hear them, or point me to something that can give me a "dummies" perspective on the scripting language, as i will be completely honest in my old age i'm developing A.D.D. and have a slightly reduced learning apptitude. :/
antp
Site Admin
Posts: 9639
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Post by antp »

Nicezia wrote: and there is no "AMC scripting for dummies"
I really should write a document like that some day, it would be useful for many people :D
Unfortunately except suggesting to see how work current script, I cannot help much more due to lack of time :/
tsjarlie
Posts: 8
Joined: 2007-08-28 20:11:54

Post by tsjarlie »

I have written a script that does an export for each movie to a .nfo file,
you place the nfo file with the movie and xbmc will recognize it ...

it isn't yet working perfect (for me it does, but I have changed some fields)
Nicezia
Posts: 14
Joined: 2008-10-17 04:41:01

Post by Nicezia »

tsjarlie wrote:I have written a script that does an export for each movie to a .nfo file,
you place the nfo file with the movie and xbmc will recognize it ...

it isn't yet working perfect (for me it does, but I have changed some fields)
You mind if i borrow that script?
How about parsing Actors, how is that handled?
Nicezia
Posts: 14
Joined: 2008-10-17 04:41:01

Post by Nicezia »

antp wrote:
Nicezia wrote: and there is no "AMC scripting for dummies"
I really should write a document like that some day, it would be useful for many people :D
Unfortunately except suggesting to see how work current script, I cannot help much more due to lack of time :/
Honestly where it stands right now, i have been able to modify one script to do basically what i need, is there anyway you can give me a quickie tutorial how to take actors from a list and transfer them as individual values to a xml format?

My Actors are usually delimited by a new line or a comma, and i'd like to be able to transfer them (by scripting) from this:

Code: Select all

Robert DeNiro
Matt LeBlanc
Susan Surandon
Mark Wahlberg
or this:

Code: Select all

Robert DeNiro, Matt LeBlanc, Susan Surandon, Mark Wahlberg
ultimately to this:

Code: Select all

<actor><name>Robert DeNiro</name></actor>
<actor><name>Matt LeBlanc</name></actor>
<actor><name>Susan Surandon</name></actor>
<actor><name>Mark Wahlberg</name></actor>
antp
Site Admin
Posts: 9639
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Post by antp »

It is quite easy, few lines of code, but now I am a little tired (1:21 AM), I'll write that later if bad4u or someone else doesn't do it before :D
antp
Site Admin
Posts: 9639
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Post by antp »

So here is a small function which will convert actors list to xml :

Code: Select all

function ActorsToXml(actors: string): string;
var
  lst: TStringList;
  i: Integer;
  s := string;
begin
  lst := TStringList.Create;
  lst.Text := StringReplace(actors, ', ', #13#10);
  for i := 0 to lst.Count - 1 do
  begin
    s := '<actor><name>' + lst.GetString(i) + '</name></actor>';
    lst.SetString(i, s);
  end;
  Result := lst.Text;
  lst.Free;
end;
(not tested)
Nicezia
Posts: 14
Joined: 2008-10-17 04:41:01

Post by Nicezia »

antp wrote:So here is a small function which will convert actors list to xml
Much appreciated!!!
You probably already know this but you da man!!!!!!! :hihi:

Just so to let you know thanks to that little snippet, I was able to write an entire script from scratch to do EXACTLEY WHAT I NEED, (the scripting model seems pretty similar to Visual Basic, at least the way you wrote that code)when i'm finished with it(tweaking some functions, I hope you don't mind if i add it to the available scripts. Now that XBMC is going multi-format, i can imagine it will be useful for some people, and I'd love to be a contributing part to this program that i love so much!

You may want to move this thread to scripting if you get the chance, since its turned into a scripting question.
antp
Site Admin
Posts: 9639
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Post by antp »

Sure, if that script could be useful to other people I would be glad to include it with other scripts ;)
Nicezia
Posts: 14
Joined: 2008-10-17 04:41:01

Post by Nicezia »

antp wrote:Sure, if that script could be useful to other people I would be glad to include it with other scripts ;)

here it is, suprisingly it took very little code to do this task

Code: Select all

(***************************************************



Ant Movie Catalog importation script

www.antp.be/software/moviecatalog/



[Infos]

Authors=Nicezia

Title=XBMC .nfo Export

Description=Exports Movies to individual .nfo files that XBMC can read for movie Information

Site=

Language=?

Version=0.03.122

Requires=3.5.1

Comments=Contains sample code written by antp to export actors

License=

GetInfo=0



[Options]



***************************************************)
program XBMCNfo;
  var
  MovieActors: string;
  SavefileName: string;
  DirSelected: string;
  FormatedData: string;
  OutToFile: TStringList;

  
  function ActorsToXml(actors: string): string;
   var
    lst: TStringList;
    i: Integer;
    s:  string;
   begin
    lst := TStringList.Create;
    lst.Text := StringReplace(actors, ', ', #13#10);
    for i := 0 to lst.Count - 1 do
      begin
        s := '   <actor><name>' + lst.GetString(i) + '</name></actor>';
        lst.SetString(i, s);
      end;
        Result := lst.Text;
        lst.Free;
   end;

  
  procedure Ask(Msg: string; var FolderLocation: string);
   begin
     if not Input('XBMCNfo', Msg, FolderLocation) then FolderLocation :='';
     IncludeTrailingPathDelimiter(FolderLocation)
  end;

  begin
    OutToFile := TStringList.Create;
    Ask('Select Folder to save NFO file for '+GetField(fieldOriginalTitle)+' to?', DirSelected)
    SaveFileName := IncludeTrailingPathDelimiter(DirSelected) + GetField(fieldOriginalTitle) + '.nfo';
    FormatedData := FormatedData +'<movie>'+#13#10;
    FormatedData := FormatedData +'   <title>'+GetField(fieldOriginalTitle)+'</title>'+#13#10;
    FormatedData := FormatedData +'   <rating>'+GetField(fieldRating)+'</rating>'+#13#10;
    FormatedData := FormatedData +'   <year>'+GetField(fieldYear)+'</year>'+#13#10;
(*  FormatedData := FormatedData +'   <top250>'+GetFeild(fieldWhatever)+'</top250>'+#13#10;
    FormatedData := FormatedData +'   <votes>'+GetField(fieldWhatever)+'</votes>'+#13#10;
    FormatedData := FormatedData +'   <outline>'+GetField(Whatever)+'</outline>'+#13#10; *)
    FormatedData := FormatedData +'   <plot>'+GetField(fieldDescription)+'</plot>'+#13#10;
    FormatedData := FormatedData +'   <tagline>'+GetField(fieldComments)+'</tagline>'+#13#10;
    FormatedData := FormatedData +'   <runtime>'+GetField(fieldLength)+'min</runtime>'+#13#10;
    FormatedData := FormatedData +'   <thumb>'+GetField(fieldOriginalTitle)+'.tbn</thumb>'+#13#10;
    FormatedData := FormatedData +'   <mpaa></mpaa>'+#13#10;
    FormatedData := FormatedData +'   <genre>'+GetField(fieldCategory)+'</genre>'+#13#10;
    FormatedData := FormatedData +'   <director>'+GetField(fieldDirector)+'</director>'+#13#10;
    FormatedData := FormatedData +'   <studio>'+GetField(fieldProducer)+'</studio>';
(* Run Actor Script here*)
    MovieActors := ActorsToXML(GetField(fieldActors));
    OutToFile.Append(UTF8Encode(FormatedData));
    OutToFile.Append(UTF8Encode(MovieActors));
    OutToFile.Append('</movie>');
    OutToFile.SaveToFile(SaveFileName);
    OutToFile.Free;
    FormatedData := ''
end.
can be downloaded from http://www.mediafire.com/?rmmqciym0yo[/url]
antp
Site Admin
Posts: 9639
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Post by antp »

Thanks ;)
Post Reply