- How to achieve that?
- How to reload a podcast by a script?
Regards.
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.
10xEugene 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.
Code: Select all
PodcastItem.RetrieveProperties
I need a sample script to reproduce the problem.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 instructionand 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.Code: Select all
PodcastItem.RetrieveProperties
The main goal is to make a script which is to be executed on schedule for updating such dynamic folders.
Hi,Eugene wrote:Hi,I need a sample script to reproduce the problem.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 instructionand 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.Code: Select all
PodcastItem.RetrieveProperties
The main goal is to make a script which is to be executed on schedule for updating such dynamic folders.
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
Code: Select all
FolderItem.ChildItems[i].Delete
tryS@gittarius wrote:Hi,Eugene wrote:Hi,I need a sample script to reproduce the problem.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 instructionand 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.Code: Select all
PodcastItem.RetrieveProperties
The main goal is to make a script which is to be executed on schedule for updating such dynamic folders.
Please try to execute the following from within "Script reading list of resources"Program does stop responding onCode: 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
Regards,Code: Select all
FolderItem.ChildItems[i].Delete
Code: Select all
iChildCount := FolderItem.ChildCount;
for i := iChildCount - 1 downto 0 do