Auto-updating collection?

Post Reply
ogre111
Posts: 3
Joined: Fri Feb 19, 2010 8:44 pm

Auto-updating collection?

Post by ogre111 »

Hi

First of all, thanks for the program, it's just great.

But I wanted to know, how a collection folder could automatically add videos to itself from a folder of my computer? For example, I made a collection named "Classical movies" and I have a folder called "Classical movies" on my computer. And when I add a movie to the folder on my computer, then it goes to the all movies and in the "Classical movies" collection.

I am not good at explaining things...
Eugene
Posts: 2940
Joined: Tue Nov 17, 2009 8:05 pm

Re: Auto-updating collection?

Post by Eugene »

Hi,
ogre111 wrote: But I wanted to know, how a collection folder could automatically add videos to itself from a folder of my computer? For example, I made a collection named "Classical movies" and I have a folder called "Classical movies" on my computer. And when I add a movie to the folder on my computer, then it goes to the all movies and in the "Classical movies" collection.

I am not good at explaining things...
In version 0.72.5 added dynamically generated folder, you can use this feature. In the folder tree on the right mouse button "Edit title", select "Dynamic (script)", press button Script

Code: Select all

const
  mfVideoWatchFoldersItemID = 'B7A1EE6A-CE07-4E09-B5ED-E51D22BBE743';  

var
  iPathOffset: Integer;
  WatchFolder: TWmsScriptMediaItem;  

function FindWatchFolder(aFolder: TWmsScriptMediaItem; const aTitle: string): TWmsScriptMediaItem;
var
  i: Integer;
begin
  Result := nil;
  if (aFolder <> nil) and aFolder.HasChildItems then
    for i := 0 to aFolder.ChildCount - 1 do
      if aFolder.ChildItems[i].HasChildItems then begin 
        if SameText(aFolder.ChildItems[i].Properties[mpiTitle], aTitle) then
          Result := aFolder.ChildItems[i]      
        else        
          Result := FindWatchFolder(aFolder.ChildItems[i], aTitle);
        if Result <> nil then
          Break            
     end;
end;

procedure ProcessFolder(aFolder: TWmsScriptMediaItem);
var
  i: Integer;
  Item: TWmsScriptMediaItem;
begin
  if (aFolder <> nil) and aFolder.HasChildItems then  
    for i := 0 to aFolder.ChildCount - 1 do begin
      Item := aFolder.ChildItems[i];    
      if Item.HasChildItems then
        ProcessFolder(Item)
      else 
        FolderItem.AddItem(Copy(ExtractFileDir(Item.Properties[mpiFilePath]), iPathOffset, 1024), Item)
    end                          
end;

begin
  WatchFolder := FindWatchFolder(WmsFindMediaFolder(mfVideoWatchFoldersItemID, ''), 'Classical movies');  
  if WatchFolder <> nil then begin  
    iPathOffset := Length(IncludeTrailingBackslash(WatchFolder.Properties[mpiFilePath]));    
    ProcessFolder(WatchFolder);
  end      
end.
Click Renew in the main form of the program.
ogre111
Posts: 3
Joined: Fri Feb 19, 2010 8:44 pm

Re: Auto-updating collection?

Post by ogre111 »

Thanks for the quick reply.

I don't seem to get it working. I updated to 0.72.5, added a collection " Movies ", then "edit name" chose "dynamic script" , pressed "script", copied the code you sent and pressed ok. Then I made a folder " Movies " in my computer and added it to the media resources of the program.
I renewed it, closed the program and started again, but nothing seems to work.
No files seem to appear in the collection.
Post Reply