awasu.user
Posts: 81
Joined: Fri Jan 06, 2017 12:50 pm

Postby awasu.user » Fri Jul 21, 2017 5:28 am

Introduction

Fx. I create folder NEWS and subfolders Europe, Asia, North America. Next I create reports:
All News - I get report from all folders in main folder NEWS (with CNN channel within) and subfolders Europe, Asia, North America
Europe News - I get report from Europe News - BBC
Asia News - I get data from asian news - Epoch Times
North America News - I get articles from North America - New York Times

all of above is make it by selecting folder and make report.

Questions

1. How return channel list used in report "Asia News"? How make the same for "All News" and other report?

Code: Select all

[i]Expected result:[/i]

"Asia News" = "Epoch Times"
"All News" = "CNN", "BBC", "Epoch Times", "New York Times"


2. How get information than BBC channel is used for get information in "All News" and "Europe News" and "CNN" only in "All News"?

Code: Select all

[i]Expected result:[/i]

"BBC" = "All News", "Europe News"
"CNN" = "All News"

3. How return channels inside specific folder or subfolder?

Code: Select all

[i]Expected result:[/i]

"Europe" = "BBC"
"NEWS" = "CNN", "BBC", "Epoch Times", "New York Times" (expected result is inlude subfolders)

Summary

For now only solution which I found is reading manually .channel file from Roaming Awasu folder to get ChannelFolder-1, from config.ini read ChannelFolderGuids and next parsing API call from directory tree to find where is my missing buddy. Is any easier solution for that?

User avatar
support
Site Admin
Posts: 3021
Joined: Fri Feb 07, 2003 12:48 pm
Location: Melbourne, Australia
Contact:

Postby support » Fri Jul 21, 2017 6:25 am

First, get the Awasu folders using either $/channels/folders/list (flat structure) or $/channels/folders/tree (tree structure).

To find out what folders a channel is in, call $/channels/list, with a verbose=1 parameter. Awasu will then return all the information about each channel, including what folder(s) they are in (although you will have to handle checking for sub-folders yourself).

To find out what reports a channel is in, get the config for each channel report using $/reports/list, again with a verbose=1 parameter. For each report, Awasu will tell you which folders it is using, and using the information from above, you can then figure out what channels will be in that report.

User avatar
support
Site Admin
Posts: 3021
Joined: Fri Feb 07, 2003 12:48 pm
Location: Melbourne, Australia
Contact:

Postby support » Fri Jul 21, 2017 6:42 am

BTW, this can get complicated, since reports can be configured to use channels in a folder (and only that folder), or channels in a folder or any sub-folder.

I would build 2 dictionaries, one that records what folders each channel is in, and another one that records all the parent folders of those folders e.g.

Code: Select all

# figure out what folders a channel is in
channel_folders["channel-id-1"] = [ "folder-id-1" , "folder-id-2" , etc... ]
channel_folders["channel-id-2"] = [ etc... ]

# figure out what parent folders a channel has
channel_parent_folders["channel-id-1"] = [ "folder-id-3" , "folder-id-4" , etc... ]
channel_parent_folders["channel-id-2"] = [ etc... ]

Then, write a function something like this:

Code: Select all

def is_channel_in_folder( channel_id , folder_id , allow_sub_folders ) :
    if channel_id not in channel_folders :
        return False # unknown channel
    if folder_id in channel_folders[channel_id] :
        return True # channel is in the specified folder
    if allow_sub_folders :
        # check if the channel is in a sub-folder of the specified folder
        if folder_id in channel_parent_folders[channel_id] :
            return True
    return False

This will simplify things a lot when you're processing reports and trying to figure out if a channel is in a report or not.


Return to “Awasu - Extensions”

Who is online

Users browsing this forum: No registered users and 1 guest