Using xAnt and sorting by Month and Year

Help each other out

Using xAnt and sorting by Month and Year

Postby scottw on Mon Dec 22, 2008 3:55 pm

I am using xAnt with Ant Movie Catalog to organize my Movie collection. What I do right now is import the movie into Ant and run the IMDB script to import all of the movie data which also imports the year. I then can sort my movies in xLobby by year. What I want is a way to be able to sort the movies by year and then month, which currently Ant does not do. Right now I get all of the movies mixed together throughout the year.

The first task I think is to get Ant to be able to pull the month from IMDB or wherever and then setup xLobby to sort with both fields.
One problem I see is using the month names (Jan. Feb. etc..) so I think using the month numbers would be better.


Is anyone else doing this????
I don't mind performing an extra step whenever I add a movie since this would be so helpful for me.

Thanks,
Scott
scottw
 
Posts: 774
Joined: Mon Feb 06, 2006 4:21 pm
Location: Glen Burnie, Maryland

Re: Using xAnt and sorting by Month and Year

Postby scottw on Tue Dec 23, 2008 5:16 pm

Ok I got it figured out with help from someone on the Ant Movie Catalog forums.
I updated my IMDB script by adding this:
Code: Select all
// Release Date
  if CanSetField(fieldSource) then
  begin
    Value := TextBetween(PageText, '<h5>Release Date:</h5>', '<');
    Value := TextBetween(Value, #13#10, #13#10);
    Value := TextAfter(Value, ' ');
    Month := TextBefore(Value, ' ', '');
    case Month of
      'January':    Month := '01';
      'February':   Month := '02';
      'March':      Month := '03';
      'April':      Month := '04';
      'May':      Month := '05';
      'June':      Month := '06';
      'July':      Month := '07';
      'August':      Month := '08';
      'September':      Month := '09';
      'October':      Month := '10';
      'November':      Month := '11';
      'December':      Month := '12';
    end;
    Value := RemainingText;
    Year := TextBefore(Value, ' ', '');
    Value := Year + Month;
    SetField(fieldSource, Value);
  end;


I added it right after the Directors section of the script and had to define the variables "Month" and "Year" as strings. You do this on the part of the script that looks like this:

Code: Select all
// ***** analyzes the page containing movie information *****

procedure AnalyzeMoviePage(PageText: string);
var
  Value, Value2, Value3, FullValue: string;


I just changed the last line to read:
Code: Select all
  Value, Value2, Value3, Year, Month, FullValue: string;


Then I changed my MoviesTemplate.xml file in Plugins/xant to look like this:

Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<database>
   <sortorder>number</sortorder>
   <sortable>
      <sort>actors</sort>
      <sort>title</sort>
      <sort>sorttitle</sort>
      <sort>genre</sort>
      <sort>director</sort>
      <sort>year</sort>
      <sort>rating</sort>
      <sort>name</sort>
      <sort>number</sort>
      <sort>starimage</sort>
      <sort>borrower</sort>
      <sort>HQ</sort>
      <sort>medialabel</sort>
      <sort>source</sort>
      <sort>yearmonth</sort>
   </sortable>
   <template/>
   <paths>
      <path/>
   </paths>
   <item>
      <parameter>$$ITEM_URL</parameter>
      <coverart>$$ITEM_PICTUREFILENAME</coverart>
      <display>$$ITEM_ORIGINALTITLE</display>
      <information>
         <name>$$ITEM_ORIGINALTITLE</name>
         <title>$$ITEM_ORIGINALTITLE</title>
         <sorttitle>$$ITEM_ORIGINALTITLE</sorttitle>
         <director>$$ITEM_DIRECTOR</director>
         <runtime>$$ITEM_LENGTH</runtime>
         <plot>$$ITEM_DESCRIPTION</plot>
         <actors>$$ITEM_ACTORS</actors>
         <year>$$ITEM_YEAR</year>
         <genre>$$ITEM_CATEGORY</genre>
         <rating>$$ITEM_RATING/10</rating>
         <number>$$ITEM_NUMBER</number>
         <borrower>$$ITEM_BORROWER</borrower>
         <starimage>skin://buttons/stars/Stars5-$$ITEM_RATING.png</starimage>
         <HQ>skin://buttons/$$ITEM_MEDIA.png</HQ>
         <medialabel>$$ITEM_MEDIA</medialabel>
         <yearmonth>$$ITEM_SOURCE</yearmonth>
      </information>
   </item>
</database>


I added the 2 lines referring to "yearmonth" (I tried to bold them but could not figure it out :D )

Now what I get in the Source field of Ant is for example: 200805 for May of 2008.
So now I can just do a "set sort order" of "-1:yearmonth" and I get my movies sorted with the newest released movies first 8)

Just figured I would share in case anyone else want to do the same.

Happy Holidays!!!!
scottw
 
Posts: 774
Joined: Mon Feb 06, 2006 4:21 pm
Location: Glen Burnie, Maryland