X-Git-Url: http://gitweb.pimeys.fr/?p=today.git;a=blobdiff_plain;f=youtube.py;fp=youtube.py;h=dfee99527ca9aa8ed2c43ff38a5920b4ae6cf200;hp=1f30801263a4f805428461fa940638ee3cad853d;hb=4ae5fb290a01ab80b4315a1468aea9b84453797a;hpb=4aab173ec192b225942118aef84c054c87491724 diff --git a/youtube.py b/youtube.py index 1f30801..dfee995 100644 --- a/youtube.py +++ b/youtube.py @@ -37,18 +37,6 @@ def parse_youtube(username, regexp=None, length=False): titles = len(titles) return titles -def load_channels(): - """Récupère les chaînes à surveiller à partir du fichier de conf.""" - with open(serverconfig.youtube_channels_file) as f: - channels = [l.strip("\n") for l in f.readlines()] - channels = [l for l in channels if not (l.startswith("#") or l.strip() == "")] - channels = [l.split("\t") for l in channels] - # Il peut y avoir plusieurs tabulations de suite, donc on enlève les chaînes vides - channels = [[i for i in l if not i == ''] for l in channels] - # [id, username, regexp] - # channels = [{"id" : l[0], "username" : l[1], "regexp" : l[2]} for l in channels] - return channels - def get_parser(username, regexp=None): """ Renvoie un parseur de chaîne youtube prêt à être appelé """ @@ -56,5 +44,5 @@ def get_parser(username, regexp=None): return parse_youtube(username, regexp, length=True) return local_parser -channels = load_channels() +channels = serverconfig.load_file(serverconfig.youtube_channels_file) functions = {id : get_parser(username, regexp) for (id, username, regexp) in channels}