diff --git a/modules/scheduling/calender_fetcher.py b/modules/scheduling/calender_fetcher.py index 13490d71de52884fb7f37edb94bcab45f92d54b6..3ecc95ceac2cc878798ee29d3f5dc71e372b4076 100644 --- a/modules/scheduling/calender_fetcher.py +++ b/modules/scheduling/calender_fetcher.py @@ -161,16 +161,6 @@ class CalendarFetcher: def __fetch_schedule_playlist__(self, schedule, id_name, fetched_schedule_entries): servicetype = "importer" - # set playlist_id (in testenvironment always null => no idea) - if id_name not in schedule or schedule[id_name] is None: - playlist_id = 1 - else: - playlist_id = schedule[id_name] - - # set url - #url = self.url["importer"] + schedule["show_name"] + "/playlists/" + str(playlist_id) - #url = self.url["importer"] + "public" + "/playlists/" + str(playlist_id) - # fetch playlists from TANK if not "show_slug" in schedule: raise ValueError("Missing 'show_slug' for schedule", schedule) @@ -178,25 +168,22 @@ class CalendarFetcher: slug = str(schedule["show_slug"]) json_response = self.__fetch_data__(servicetype, "${SLUG}", slug) - # use testdata if wanted - if not json_response and self.config.get("use_test_data"): - self.logger.warn("Using test-data for fetch-schedule-playlist") - use_testdata = True - # if a playlist is already fetched, do not fetch it again for entry in fetched_schedule_entries: if entry["playlist_id"] == schedule[id_name]: self.logger.debug("playlist #" + str(schedule[id_name]) + " already fetched") return entry - if use_testdata: + if self.config.get("use_test_data"): # FIXME move hardcoded test-data to separate testing logic. + self.logger.warn("Using test-data for fetch-schedule-playlist") json_response = self.create_test_data(id_name, schedule) # convert to list schedule_entries = simplejson.loads(json_response) + if "results" in schedule_entries: + schedule_entries = schedule_entries["results"][0] - if "entries" in schedule_entries: for entry in schedule_entries["entries"]: if entry["uri"].startswith("file"): entry["filename"] = self.convert_to_filename(entry["uri"]) @@ -209,7 +196,7 @@ class CalendarFetcher: # convert to normal filename e = self.config.get("audiofolder") + "/" + uri[7:] + ".flac" if not os.path.isfile(e): - self.logger.warning("File", e, "does not exist!") + self.logger.warning("File %s does not exist!" % e) return e # ------------------------------------------------------------------------------------------ #