def launch_the_stream(): parser = create_parser() if len(argv) == 1: parser.print_help() exit(1) arguments = parser.parse_args() rv = 0 statistics = UserStat(APPLICATION_NAME, STAT_FILE_NAME) statistics.load() nicknames = Nicknames(APPLICATION_NAME, ALIAS_FILE_NAME) nicknames.load() if arguments.stat: print(str(statistics)) elif arguments.aliases: print(str(nicknames)) elif arguments.clear: trimmed = statistics.fltr(lambda key, value: value > int(arguments.clear)) statistics.save() print("Statistics cleared: {0}".format(trimmed)) elif (arguments.let and len(arguments.let) == 2): (nick, URL) = arguments.let nicknames.assign(nick, URL) # Extract the last part of URL path as a streamer nick streamer = [x for x in parse(URL)['path'].split('/') if x][-1] trimmed = statistics.fltr(lambda key, value: streamer not in key) statistics.save() nicknames.save() print("{0} was assigned to {1}; Statistics cleared: {2}".format(nick, URL, trimmed)) else: rv = assemble_command(arguments, statistics, nicknames) return rv
def record_the_stream(): command_parser = create_parser() if len(argv) == 1: command_parser.print_help() exit(1) arguments = command_parser.parse_args() rv = 0 nicknames = Nicknames(LAUNCHER_APPLICATION_NAME, ALIAS_FILE_NAME) nicknames.load() if arguments.aliases: print(str(nicknames)) else: rv = record(arguments, nicknames) return rv