Problem with "set filter"

Help each other out

Problem with "set filter"

Postby orbital on Fri Dec 21, 2007 8:22 pm

Hi everybody

my knowledge in informatic (as well as in english^^) are very bad, so i need your help on a probably easy fix to do.

I have a problem with the filter of my movie. I want to filter using "set filter Genre", which is automatic with the skin I use (colbyskin2).

If in my database, the genre of the film is "Action, Comedy", Im expecting that the filter will separate the two genre, like its doing with the actors.

As a result of this filter, if I have lets say 3 films with this genre :

Lethal Weapon : "Action, Comedy"
Bervelly hills cop : "Comedy, Action"
Shrek 3 :"Animation, Comedy"

and if I filter by "Comedy", the filter will return me the 3 results
"Action, Comedy"
"Comedy, Action"
"Animation, Comedy"

But I want it to return just the genre "Comedy", like its doing with the actors (no repetition of a unique actor)

With a database of about 2000 movies, I let you imagine the number of different combinations of genre, and its quite impossible to use this feature.

I also notice than "set filter actors" is filtering the way I want, whereas "set filters Actors" (with a maj) is filtering the same way than "Genre", that mean the wrong way for me (display of the complete list of actors of a movie as a result, instead of a unique actor).

I so tried to replace "set filter Genre" by "set filter genre"... but as expected with no success ^^

As im very bad in informatic, Im probably missing something, but your help will be greatful :)

Thank you very much for your help, thank you for this very good media center, and merry christmas to all of you :D
orbital
 
Posts: 4
Joined: Fri Dec 21, 2007 8:04 pm

Re: Problem with "set filter"

Postby slaman on Tue Jan 08, 2008 5:22 am

You need to separate each genre value using a "/" delimiter instead of having them separated by the "," character... It's annoying, but possible to write a perl script to do the replace for you...

I had to do the same thing with actors, since when you download the information using the imdb spider, it only separates the values using commas...
slaman
 
Posts: 145
Joined: Sat Oct 14, 2006 10:30 pm

Re: Problem with "set filter"

Postby tswhite70 on Tue Jan 08, 2008 6:08 pm

Slaman is right the "/" character in a field tells Xlobby to treat the items as individual filter criteria. You can modify all your genre fields or create a new field like "filtergenre" and populate it with "/" separated items. I've done that in some cases because I prefer to view the information as comma separated but also would like be able to filter by individual item.

I wrote up a quick vbs script to fix your issue. Copy the text in the code block to a txt file and save as GenreUpdate.vbs in your Xlobby\Databases directory. Open a command prompt, navigate to Xlobby\Databases and run: GenreUpdate.vbs movies.xml

The script will parse your current movies.xml and produce and new file (new_movies.xml) with genre fields updated to replace commas with the slash. Then just rename the files (save the old one just in case) and restart Xlobby.

Code: Select all
'*****************************************************************************************
'**********     GenreUpdate.vbs
'**********   v 1.0 1/8/2008
'**********     written by TSW
'*****************************************************************************************
' Output
'               new_movies.xml
' Input
'      Xlobby movies xml database
'

Option Explicit

Dim MoviePath_str, PluginPath_str, testpath_str, path, MovieFolder_str
Dim sw, sr, rw
Dim txt, test
Dim WshShell, logsw, newFSO, oldFSO, objargs

Set WshShell = WScript.CreateObject("WScript.Shell")

Set objArgs = Wscript.Arguments
If objArgs.Count = 1 Then
        MoviePath_str = objArgs(0)
Else
    wscript.echo  "Usage: GenreUpdate.vbs <movies.xml>"
    wscript.quit
End If

wscript.echo  "Opening Movies.xml: " & MoviePath_str

PluginPath_str = WshShell.CurrentDirectory
testpath_str = PluginPath_str

'Open old and new movies.xml files
Set newFSO = CreateObject("Scripting.FileSystemObject")
Set oldFSO = CreateObject("Scripting.FileSystemObject")

'Open XML file for output and write header information
path= testpath_str & "\movies.xml"
wscript.echo  "Open output file: " & path
Set sw = newFSO.CreateTextFile("new_movies.xml", 8,false)
Set rw = oldFSO.OpenTextFile(MoviePath_str)

'Start reading the old XML file
wscript.echo  "Starting Update!"
ReWrite()
wscript.echo  "New Movies.xml file has been created! Filename: new_movies.xml"
sw.Close
rw.Close
'End Script!

Sub ReWrite()
   
   Do Until rw.AtEndOfStream
   
      txt = rw.readline
      test = InStr(txt,"<genre>")
      if test>0 then   
         txt = Replace(txt," , ","/")
         txt = Replace(txt," ,","/")
         txt = Replace(txt,", ","/")
         txt = Replace(txt,",","/")
      End if
      sw.writeline(txt)
   Loop
       
End Sub

good luck,
tsw
tswhite70
 
Posts: 318
Joined: Tue Jan 06, 2004 3:44 pm
Location: Houston, Tx

Re: Problem with "set filter"

Postby orbital on Thu Jan 10, 2008 7:26 am

Thank you sooo much!!

I will try it tonight, I hope it will work!!

I will tell you if it was ok :D


Have a nice day!
orbital
 
Posts: 4
Joined: Fri Dec 21, 2007 8:04 pm

Re: Problem with "set filter"

Postby orbital on Thu Jan 10, 2008 8:46 am

just another thing :

If what your saying is true, why Xlobby is capable to treat the field "actors" as individual items, even with coma? ("set filter Actors" is treating the items as global filter, and "set filter actors" as individual, still with coma)

Is it a limitation of xlobby?

Thank you very much for your help!
orbital
 
Posts: 4
Joined: Fri Dec 21, 2007 8:04 pm

Re: Problem with "set filter"

Postby tswhite70 on Thu Jan 10, 2008 7:45 pm

Wow - I just tested and saw what you said about using "set filter actor" vs. "set filter Actor". After 4 years of using XL I'm pretty stunned I never knew that, nor can I ever remember seeing a post about it when it seems it should have been one of the first things I learned (I must have missed that day in Xlobby 101 class :)).

It appears, at least to me, that Steven must have hardcoded that behaviour for the Actors field and the Directors field. As you noted it does not work with the Genre field (nor does it work with the Rating field in my testing, or with the Actors field if I rename it to something else like "actors2"). Steven must hard coded that behaviour for Actors and Directors because the XL internal Spider code automatically places "," between variable items which is how he was spidering those categories from the original spiders.

Kudos to you for discovering this behaviour!
good luck,
tsw

btw - All my testing was on the FreeLobby version...
tswhite70
 
Posts: 318
Joined: Tue Jan 06, 2004 3:44 pm
Location: Houston, Tx

Re: Problem with "set filter"

Postby orbital on Fri Jan 11, 2008 4:29 pm

I discovered this trick by switching between different skin, I noticed that on some skins, the search by actors (and director)s was global, and on other was individual, and the only difference in the setting on the filter was the Maj or the Min.

Thank your for replying, I guess we should ask Steven to add this feature for other fields (like genre in my case) in the next version of xlobby ^^

Anyway, for the moment I will use "/" instead of ","
Big thanks for your code that works perfectly and do the job :)
orbital
 
Posts: 4
Joined: Fri Dec 21, 2007 8:04 pm

Re: Problem with "set filter"

Postby slaman on Wed Feb 06, 2008 7:21 pm

tswhite70 - thank you SO much for that vbs program... I can finally download actor information for my movies. I was getting annoying manually replacing the "," with "/" everything i spidered the movie info!
slaman
 
Posts: 145
Joined: Sat Oct 14, 2006 10:30 pm

Re: Problem with "set filter"

Postby slaman on Wed Feb 06, 2008 7:35 pm

One last thing - instead of creating a new file called new_movies.xml - can I replace the old one? I'm not a VB expert, but if I create a "refresh" button in Xlobby to run this VBS, it will make my life so much easier!

EDIT: I created a .bat file to execute the VBS script, delete the old movies.xml and then rename new_movies.xml to movies.xml

The only problem is that the DOS window pops up when I launch it from within XLobby using an event... Can I simulate this same activity within the VBS script?
slaman
 
Posts: 145
Joined: Sat Oct 14, 2006 10:30 pm

Re: Problem with "set filter"

Postby tswhite70 on Wed Feb 06, 2008 9:04 pm

slaman - New code below to copy movies.xml to movies.xml.old and move new_movies.xml to movies.xml at the end of the script. You should be able to create an event to execute the script, and then run a category refresh to pull in the new information. Once you've got it working you can comment out the echo's if you need to (just place a ' in front every wscript.echo).

The batch file works just as good, you just need to set the OS:Execute event Window Type to "Hidden". I have to ask though why you have to keep running the script, I actually wrote it thinking you would run it once and never need it again. What spider are you using that keeps separating genre's with commas - or are you not getting your data via the spiders?

good luck,
tsw

Code: Select all
'*****************************************************************************************
'**********     GenreUpdate.vbs
'**********   v 1.1 2/6/2008
'**********     written by TSW
'*****************************************************************************************
' Output
'               new_movies.xml
' Input
'      Xlobby movies xml database
'

Option Explicit

Dim MoviePath_str, PluginPath_str, testpath_str, path, MovieFolder_str
Dim sw, sr, rw
Dim txt, test
Dim WshShell, logsw, newFSO, oldFSO, objargs

Set WshShell = WScript.CreateObject("WScript.Shell")

Set objArgs = Wscript.Arguments
If objArgs.Count = 1 Then
        MoviePath_str = objArgs(0)
Else
    wscript.echo  "Usage: GenreUpdate.vbs <movies.xml>"
    wscript.quit
End If

wscript.echo  "Opening Movies.xml: " & MoviePath_str

PluginPath_str = WshShell.CurrentDirectory
testpath_str = PluginPath_str

'Open old and new movies.xml files
Set newFSO = CreateObject("Scripting.FileSystemObject")
Set oldFSO = CreateObject("Scripting.FileSystemObject")

'Open XML file for output and write header information
path= testpath_str & "\movies.xml"
wscript.echo  "Open output file: " & path
Set sw = newFSO.CreateTextFile("new_movies.xml", 8,false)
Set rw = oldFSO.OpenTextFile(MoviePath_str)

'Start reading the old XML file
wscript.echo  "Starting Update!"
ReWrite()
wscript.echo  "New Movies.xml file has been created! Filename: new_movies.xml"
sw.Close
rw.Close

' Copy movies.xml to movies.xml.old and move new_movies.xml to movies.xml
If newFSO.FileExists(testpath_str & "\new_movies.xml") Then
   newFSO.CopyFile testpath_str & "\movies.xml", testpath_str & "\movies.xml.old", true
   newFSO.DeleteFile testpath_str & "\movies.xml"
                newFSO.MoveFile testpath_str & "\new_movies.xml", testpath_str & "\movies.xml"
End If


'End Script!


Sub ReWrite()

   Do Until rw.AtEndOfStream
   
      txt = rw.readline
      test = InStr(txt,"<genre>")
      if test>0 then   
         txt = Replace(txt," , ","/")
         txt = Replace(txt," ,","/")
         txt = Replace(txt,", ","/")
         txt = Replace(txt,",","/")
      End if
      sw.writeline(txt)
   Loop
       
End Sub

tswhite70
 
Posts: 318
Joined: Tue Jan 06, 2004 3:44 pm
Location: Houston, Tx

Re: Problem with "set filter"

Postby slaman on Wed Feb 06, 2008 9:52 pm

Ok, figured out how to do it in VBS - thanks for the start tswhite!!!

Now the only problem is that XLobby won't recognize the changes until after I reboot... is there a way to clear the "cached" databases, so that my VBS script is reflected in XLobby immediately?

Xlobby - Clear Cache and Category - Refresh events don't work.

Here's the VBS code:
Code: Select all
    '*****************************************************************************************
    '**********     MoviesUpdate.vbs
    '**********   v 1.1 2/6/2008
    '**********     written by TSW
    '**********     updated by slaman
    '*****************************************************************************************
    ' Output
    '               new__movies.xml
    ' Input
    '      Xlobby movies xml database
    '

    Option Explicit

    Dim MoviePath_str, PluginPath_str, testpath_str, path, MovieFolder_str
    Dim sw, sr, rw
    Dim txt, genresLine, actorsLine, languagesLine, directorsLine
    Dim WshShell, logsw, newFSO, oldFSO, objargs, oldFile, newFile

    Set WshShell = WScript.CreateObject("WScript.Shell")

    Set objArgs = Wscript.Arguments
    If objArgs.Count = 1 Then
            MoviePath_str = objArgs(0)
    Else
        wscript.quit
    End If

    PluginPath_str = WshShell.CurrentDirectory
    testpath_str = PluginPath_str

    'Open old and new movies.xml files
    Set newFSO = CreateObject("Scripting.FileSystemObject")
    Set oldFSO = CreateObject("Scripting.FileSystemObject")

    'Open XML file for output and write header information
    path= testpath_str & "\movies.xml"
    Set sw = newFSO.CreateTextFile("new_movies.xml", 8,false)
    Set rw = oldFSO.OpenTextFile(MoviePath_str)

    'Start reading the old XML file
    ReWrite()
    sw.Close
    rw.Close
   
    Set oldFile = oldFSO.GetFile(".\movies.xml")
    oldFile.Delete

    Set newFile = newFSO.GetFile(".\new_movies.xml")
    newFile.Move ".\movies.xml"

    'End Script!

    Sub ReWrite()
       
       Do Until rw.AtEndOfStream
       
          txt = rw.readline
          genresLine = InStr(txt,"<genre>")
          if genresLine > 0 then   
             txt = Replace(txt," , ","/")
             txt = Replace(txt," ,","/")
             txt = Replace(txt,", ","/")
             txt = Replace(txt,",","/")
          End if
     languagesLine = InStr(txt,"<language>")
          if languagesLine > 0 then   
             txt = Replace(txt," , ","/")
             txt = Replace(txt," ,","/")
             txt = Replace(txt,", ","/")
             txt = Replace(txt,",","/")
          End if
          actorsLine = InStr(txt,"<actors>")
          if actorsLine > 0 then   
             txt = Replace(txt," , ","/")
             txt = Replace(txt," ,","/")
             txt = Replace(txt,", ","/")
             txt = Replace(txt,",","/")
          End if
          directorsLine = InStr(txt,"<director>")
          if directorsLine > 0 then   
             txt = Replace(txt," , ","/")
             txt = Replace(txt," ,","/")
             txt = Replace(txt,", ","/")
             txt = Replace(txt,",","/")
          End if
          sw.writeline(txt)
       Loop
           
    End Sub
slaman
 
Posts: 145
Joined: Sat Oct 14, 2006 10:30 pm

Re: Problem with "set filter"

Postby slaman on Wed Feb 06, 2008 9:53 pm

Just posted before I saw what you wrote! I actually need these separators for actors, languages, directors, and genres... all use comma delimiters, and my skin only uses set filter, and not the specific ones for actors or directors.

EDIT: For some reason, when I use the category Refresh event, it deletes half my movie entries!
slaman
 
Posts: 145
Joined: Sat Oct 14, 2006 10:30 pm

Re: Problem with "set filter"

Postby tswhite70 on Thu Feb 07, 2008 8:09 pm

uhh-ohhh! If you run a category refresh on a "templated" db then it will run an actual refresh\update if I'm not mistaken. This is not what you want to do. You only want to edit the DB to fix your filter criteria after you've added new media - correct?. I think you should do this offline if it's a templated db - maybe someone else has more experience with editing templated db's and can point you in the right direction.

You are using the Pre-Calrad XL right (ie free lobby)? The pay versions don't allow online external edits of the db's.

tsw
tswhite70
 
Posts: 318
Joined: Tue Jan 06, 2004 3:44 pm
Location: Houston, Tx