From 91bda47ed007e2b004467afc92cd7cb14be02601 Mon Sep 17 00:00:00 2001 From: David Trattnig <david.trattnig@o94.at> Date: Mon, 8 Jun 2020 12:46:40 +0200 Subject: [PATCH] Utility to convert URI to actual filepath. --- modules/base/utils.py | 20 ++++++++++++++++++++ modules/scheduling/calender_fetcher.py | 16 ---------------- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/modules/base/utils.py b/modules/base/utils.py index e063b8b3..b749a409 100644 --- a/modules/base/utils.py +++ b/modules/base/utils.py @@ -29,6 +29,9 @@ class EngineUtil: """ A class for Engine utilities. """ + + + @staticmethod def get_channel_type(uri): """ @@ -47,6 +50,23 @@ class EngineUtil: return ChannelType.LIVE + + @staticmethod + def uri_to_filepath(base_dir, uri): + """ + Converts a file-system URI to an actual, absolute path to the file. + + Args: + basi_dir (String): The location of the audio store. + uri (String): The URI of the file + + Returns: + path (String): Absolute file path + """ + return base_dir + "/" + uri[7:] + ".flac" + + + @staticmethod def get_entries_string(entries): """ diff --git a/modules/scheduling/calender_fetcher.py b/modules/scheduling/calender_fetcher.py index aa8c4293..e33258a0 100644 --- a/modules/scheduling/calender_fetcher.py +++ b/modules/scheduling/calender_fetcher.py @@ -301,22 +301,6 @@ class CalendarFetcher: - def convert_to_filename(self, uri): - """ - Converts a file-system URI to an actual, absolute path to the file. - - Args: - uri (String): The URI of the file - - Returns: - path (String): Absolute file path - """ - e = self.config.get("audiofolder") + "/" + uri[7:] + ".flac" - if not os.path.isfile(e): - self.logger.warning("File %s does not exist!" % e) - return e - - def __fetch_data__(self, type, url): """ -- GitLab