]> gitweb.pimeys.fr Git - today.git/blobdiff - youtube.py
On généralise load_channels à un load de n'importe quel fichier de conf
[today.git] / youtube.py
index 1f30801263a4f805428461fa940638ee3cad853d..dfee99527ca9aa8ed2c43ff38a5920b4ae6cf200 100644 (file)
@@ -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}