Podcast auto reload

Internet TV, Radio, Podcasts
Post Reply
S@gittarius
Posts: 98
Joined: Sat May 08, 2010 8:12 pm

Podcast auto reload

Post by S@gittarius »

I am trying to make an Internet podcast to be reloaded on schedule but so far in vain. I’d like to have it refreshed on server/program’s startup. Doing so on demand from TV and from the podcast’s context menu are the only ways I found so far.
  1. How to achieve that?
  2. How to reload a podcast by a script?

Regards.
Eugene
Posts: 2940
Joined: Tue Nov 17, 2009 8:05 pm

Re: Podcast auto reload

Post by Eugene »

Script to update some podcast feed

Code: Select all

function FindFolder(aItem: TWmsScriptMediaItem; const aTitlePath: string): TWmsScriptMediaItem;
var
  i, j: Integer;  
  sTitle: string;
begin
  Result := nil;
  if aItem.HasChildItems then begin
    i := Pos('\', aTitlePath);  
    if i > 0 then   
      sTitle := Copy(aTitlePath, 1, i - 1)    
    else                                    
      sTitle := aTitlePath;
    for j := 0 to aItem.ChildCount - 1 do
      if SameText(aItem.ChildItems[j].Properties[mpiTitle], sTitle) then begin
        if i > 0 then
          Result := FindFolder(aItem.ChildItems[j], Copy(aTitlePath, i + 1, Length(aTitlePath)))
        else
          Result := aItem.ChildItems[j];
        Break
      end                                
  end
end;

var
  PodcastItem: TWmsScriptMediaItem;
begin
  PodcastItem := FindFolder(WmsFindMediaFolder(mfVideoPodcastsFolderItemID, ''), 'Hulu\Channels\Comedy');
  if PodcastItem <> nil then begin
    PodcastItem.RetrieveProperties;
    WmsDatabaseAutoSave
  end      
end.
S@gittarius
Posts: 98
Joined: Sat May 08, 2010 8:12 pm

Re: Podcast auto reload

Post by S@gittarius »

Eugene wrote:Script to update some podcast feed

Code: Select all

function FindFolder(aItem: TWmsScriptMediaItem; const aTitlePath: string): TWmsScriptMediaItem;
var
  i, j: Integer;  
  sTitle: string;
begin
  Result := nil;
  if aItem.HasChildItems then begin
    i := Pos('\', aTitlePath);  
    if i > 0 then   
      sTitle := Copy(aTitlePath, 1, i - 1)    
    else                                    
      sTitle := aTitlePath;
    for j := 0 to aItem.ChildCount - 1 do
      if SameText(aItem.ChildItems[j].Properties[mpiTitle], sTitle) then begin
        if i > 0 then
          Result := FindFolder(aItem.ChildItems[j], Copy(aTitlePath, i + 1, Length(aTitlePath)))
        else
          Result := aItem.ChildItems[j];
        Break
      end                                
  end
end;

var
  PodcastItem: TWmsScriptMediaItem;
begin
  PodcastItem := FindFolder(WmsFindMediaFolder(mfVideoPodcastsFolderItemID, ''), 'Hulu\Channels\Comedy');
  if PodcastItem <> nil then begin
    PodcastItem.RetrieveProperties;
    WmsDatabaseAutoSave
  end      
end.
10x
I'll give it a try.

Regards
S@gittarius
Posts: 98
Joined: Sat May 08, 2010 8:12 pm

Re: Podcast auto reload

Post by S@gittarius »

Hi Eugene,
I am experiencing a little problem while updating resource database as follows. I have podcast folders generated by script which dynamically adds/removes items. To be clearer let’s say you have a “Last week” folder where you add items from the last 7 days (if they aren’t already there) for a specific resource (Youtube subscription) and remove items which are older than 1 week. One would ask what all is about. The reason for using such a script is that Youtube does not provide such functionality through its API. So everything works find while manually updating the podcast from its context menu. Now when I invoke the update from the script above WMS stops responding on instruction

Code: Select all

PodcastItem.RetrieveProperties
and the only way out of the situation is to kill the process. I found through testing that removing items from target folder causes the problem under <...>.RetrieveProperties procedure. In the same time there is no problem adding new items.
The main goal is to make a script which is to be executed on schedule for updating such dynamic folders.
Regards.
Eugene
Posts: 2940
Joined: Tue Nov 17, 2009 8:05 pm

Re: Podcast auto reload

Post by Eugene »

Hi,
S@gittarius wrote:I am experiencing a little problem while updating resource database as follows. I have podcast folders generated by script which dynamically adds/removes items. To be clearer let’s say you have a “Last week” folder where you add items from the last 7 days (if they aren’t already there) for a specific resource (Youtube subscription) and remove items which are older than 1 week. One would ask what all is about. The reason for using such a script is that Youtube does not provide such functionality through its API. So everything works find while manually updating the podcast from its context menu. Now when I invoke the update from the script above WMS stops responding on instruction

Code: Select all

PodcastItem.RetrieveProperties
and the only way out of the situation is to kill the process. I found through testing that removing items from target folder causes the problem under <...>.RetrieveProperties procedure. In the same time there is no problem adding new items.
The main goal is to make a script which is to be executed on schedule for updating such dynamic folders.
I need a sample script to reproduce the problem.
S@gittarius
Posts: 98
Joined: Sat May 08, 2010 8:12 pm

Re: Podcast auto reload

Post by S@gittarius »

Eugene wrote:Hi,
S@gittarius wrote:I am experiencing a little problem while updating resource database as follows. I have podcast folders generated by script which dynamically adds/removes items. To be clearer let’s say you have a “Last week” folder where you add items from the last 7 days (if they aren’t already there) for a specific resource (Youtube subscription) and remove items which are older than 1 week. One would ask what all is about. The reason for using such a script is that Youtube does not provide such functionality through its API. So everything works find while manually updating the podcast from its context menu. Now when I invoke the update from the script above WMS stops responding on instruction

Code: Select all

PodcastItem.RetrieveProperties
and the only way out of the situation is to kill the process. I found through testing that removing items from target folder causes the problem under <...>.RetrieveProperties procedure. In the same time there is no problem adding new items.
The main goal is to make a script which is to be executed on schedule for updating such dynamic folders.
I need a sample script to reproduce the problem.
Hi,
Please try to execute the following from within "Script reading list of resources"

Code: Select all

  FolderItem.Sort('-mpCreateDate');
//Purge oldest items
  dtOldestTime := IncMonth(Now, -7);
  for i := FolderItem.ChildCount - 1 downto 0 do begin
    if dtOldestTime > strtodatetime(FolderItem.ChildItems[i].Properties[mpiCreateDate]) then FolderItem.ChildItems[i].Delete
    else break;
  end
Program does stop responding on

Code: Select all

FolderItem.ChildItems[i].Delete
Regards,
Eugene
Posts: 2940
Joined: Tue Nov 17, 2009 8:05 pm

Re: Podcast auto reload

Post by Eugene »

S@gittarius wrote:
Eugene wrote:Hi,
S@gittarius wrote:I am experiencing a little problem while updating resource database as follows. I have podcast folders generated by script which dynamically adds/removes items. To be clearer let’s say you have a “Last week” folder where you add items from the last 7 days (if they aren’t already there) for a specific resource (Youtube subscription) and remove items which are older than 1 week. One would ask what all is about. The reason for using such a script is that Youtube does not provide such functionality through its API. So everything works find while manually updating the podcast from its context menu. Now when I invoke the update from the script above WMS stops responding on instruction

Code: Select all

PodcastItem.RetrieveProperties
and the only way out of the situation is to kill the process. I found through testing that removing items from target folder causes the problem under <...>.RetrieveProperties procedure. In the same time there is no problem adding new items.
The main goal is to make a script which is to be executed on schedule for updating such dynamic folders.
I need a sample script to reproduce the problem.
Hi,
Please try to execute the following from within "Script reading list of resources"

Code: Select all

  FolderItem.Sort('-mpCreateDate');
//Purge oldest items
  dtOldestTime := IncMonth(Now, -7);
  for i := FolderItem.ChildCount - 1 downto 0 do begin
    if dtOldestTime > strtodatetime(FolderItem.ChildItems[i].Properties[mpiCreateDate]) then FolderItem.ChildItems[i].Delete
    else break;
  end
Program does stop responding on

Code: Select all

FolderItem.ChildItems[i].Delete
Regards,
try

Code: Select all

  iChildCount := FolderItem.ChildCount;
  for i := iChildCount - 1 downto 0 do
Not everything is working properly, but AV is not happening.
S@gittarius
Posts: 98
Joined: Sat May 08, 2010 8:12 pm

Re: Podcast auto reload

Post by S@gittarius »

I gave it a try but with no success. To be clearer I invoke it through Settings -> Media-resources -> Processing where I’ve put your script to find the podcast and set a button on the main form. The actual script which does the problem is under podcast’s “Script reading list of resources” property. So when I press the button on the main form your script finds the podcast and invokes the second piece of code which goes well and adds new items if there are any to be added and then freezes on .Delete procedure.

Regards
Eugene
Posts: 2940
Joined: Tue Nov 17, 2009 8:05 pm

Re: Podcast auto reload

Post by Eugene »

I checked in “Script reading list of resources”
S@gittarius
Posts: 98
Joined: Sat May 08, 2010 8:12 pm

Re: Podcast auto reload

Post by S@gittarius »

Hi,
Any update on the subject?

Regards
Post Reply