From c3c3e51c38a88a4de53481eae6af1484ba63f99f Mon Sep 17 00:00:00 2001 From: Robert Goldmann <deadlocker@gmx.de> Date: Thu, 9 Apr 2020 21:19:19 +0200 Subject: [PATCH] externalized version --- SaveMyPlaylist.py | 17 +++++------------ version.json | 7 +++++++ 2 files changed, 12 insertions(+), 12 deletions(-) create mode 100644 version.json diff --git a/SaveMyPlaylist.py b/SaveMyPlaylist.py index 37ad73f..e8fd475 100644 --- a/SaveMyPlaylist.py +++ b/SaveMyPlaylist.py @@ -9,8 +9,6 @@ import googleapiclient.discovery import googleapiclient.errors import youtube_dl -VERSION = (2, 0, 0) - def prepare_logging() -> logging.Logger: LOG_FORMAT = '[%(levelname)-7s] - %(asctime)s - %(message)s' @@ -65,7 +63,10 @@ class SaveMyPlaylist: ILLEGAL_CHARS = ['NUL', '\',''//', ':', '*', '"', '<', '>', '|'] def __init__(self, apiKey, playlistId): - logger.info('### SaveMyPlaylist v{} ###'.format('.'.join(str(i) for i in VERSION))) + with open('version.json', 'r', encoding='utf-8') as f: + VERSION = json.load(f)['version'] + + logger.info('### SaveMyPlaylist {} ###'.format(VERSION['name'])) logger.info('=============================') self._apiKey = apiKey self._playlistId = playlistId @@ -160,17 +161,9 @@ class SaveMyPlaylist: return fileName -def run(): +if __name__ == '__main__': with open("config/settings.json", "r") as f: SETTINGS = json.load(f) saveMyPlaylist = SaveMyPlaylist(SETTINGS['apiKey'], SETTINGS['playlistId']) saveMyPlaylist.download_items(SETTINGS['destinationFolder'], SETTINGS['skipDownload']) - - -if __name__ == '__main__': - if len(sys.argv) > 1: - if sys.argv[1] == '--version': - print('.'.join(str(part) for part in VERSION)) - else: - run() diff --git a/version.json b/version.json new file mode 100644 index 0000000..cda001a --- /dev/null +++ b/version.json @@ -0,0 +1,7 @@ +{ + "version": { + "name": "v2.0.0", + "code": 5, + "date": "17.10.19" + } +} \ No newline at end of file -- GitLab