import sys import os import win32api import re # --- CHANNEL UPDATE FUNCTIONS ---------------------------------------- def enableAutoUpdate( channelConfigFilename ) : win32api.WriteProfileVal( "Settings" , "IsAutoUpdateEnabled" , "1" , channelConfigFilename ) def disableAutoUpdate( channelConfigFilename ) : win32api.WriteProfileVal( "Settings" , "IsAutoUpdateEnabled" , "0" , channelConfigFilename ) # --- CHANNEL FILTER FUNCTIONS ---------------------------------------- def checkChannelFolders( channelConfigFilename ) : # check if the channel is in any of the folders if len(CHANNEL_FOLDERS) == 0 : return True for cf in CHANNEL_FOLDERS : buf = open( channelConfigFilename , "r" ).read() if re.search( "^ChannelFolder-\\d+\\s*=\\s*%s$" % cf , buf , re.MULTILINE ) : return True return False # --- GLOBAL CONFIGURATION -------------------------------------------- # Set this to your Awasu's roaming data directory. The easiest way to find this is: # - open Awasu's About box # - go to the System page # - click on "Roaming data" ROAMING_DATA_DIR = "..." # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Set this to a list of folders a channel must be in to be processed (comma-separated). # To get your Awasu's folder ID's, enter this in a browser: # http://localhost:2604/channels/folders/list?token=... # where "..." is the API token (set in Advanced page of the Program Options). CHANNEL_FOLDERS = [ "..." ] # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Set this to a list of functions that will filter channels to be processed. CHANNEL_FILTERS = [ checkChannelFolders ] # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Set this to a list of functions that will update the configuration # for channels that pass the filters. CHANNEL_UPDATES = [ disableAutoUpdate ] # --- MAIN ------------------------------------------------------------ # process each channel channelsDir = os.path.join( ROAMING_DATA_DIR , "Channels" ) for fname in os.listdir( channelsDir ) : # get the next channel extn = os.path.splitext( fname )[1].lower() if extn[0] == "." : extn = extn[1:] if extn != "channel" : continue channelConfigFilename = os.path.join( channelsDir , fname ) # run the channel through the filters rc = True for cf in CHANNEL_FILTERS : if not cf( channelConfigFilename ) : rc = False break if not rc : continue # process the channel print "Updating channel: %s" % fname for cu in CHANNEL_UPDATES : cu( channelConfigFilename )