From af7db1e2e7eea32763e0a76473e6c34e9ea3f565 Mon Sep 17 00:00:00 2001 From: Ronnie Sahlberg Date: Sun, 19 Nov 2023 16:46:15 +1000 Subject: [PATCH] Pull snd0 from github cache if available Signed-off-by: Ronnie Sahlberg --- pop-fe-ps3.py | 2 +- pop-fe-psp.py | 2 +- pop-fe.py | 13 ++++++++++++- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/pop-fe-ps3.py b/pop-fe-ps3.py index 018eb52..373fcb2 100755 --- a/pop-fe-ps3.py +++ b/pop-fe-ps3.py @@ -758,7 +758,7 @@ def on_create_pkg(self): if self.snd0_disabled == 'off': snd0 = self.builder.get_variable('snd0_variable').get() if snd0[:24] == 'https://www.youtube.com/': - snd0 = popfe.get_snd0_from_link(snd0) + snd0 = popfe.get_snd0_from_link(snd0, subdir=self.subdir) if snd0: temp_files.append(snd0) diff --git a/pop-fe-psp.py b/pop-fe-psp.py index 3f3663c..a13fc72 100755 --- a/pop-fe-psp.py +++ b/pop-fe-psp.py @@ -549,7 +549,7 @@ def on_create_eboot(self): snd0 = self.builder.get_variable('snd0_variable').get() if snd0[:24] == 'https://www.youtube.com/': - snd0 = popfe.get_snd0_from_link(snd0) + snd0 = popfe.get_snd0_from_link(snd0, subdir=self.subdir) if snd0: temp_files.append(snd0) diff --git a/pop-fe.py b/pop-fe.py index f4803ee..b5ceb62 100755 --- a/pop-fe.py +++ b/pop-fe.py @@ -450,6 +450,17 @@ def convert_snd0_to_at3(snd0, at3, duration, max_size, subdir = './'): # caller adds the wav file to temp_files def get_snd0_from_link(link, subdir='./'): + _h = hashlib.md5(link.encode('utf-8')).hexdigest() + f = 'https://github.com/sahlberg/pop-fe-assets/raw/master/snd0/' + _h + ret = requests.get(f, stream=True) + if ret.status_code == 200: + print('Found cached prebuilt SND0', f) + _d = subdir + 'SND0.tmp' + with open(_d, 'wb') as o: + o.write(ret.content) + temp_files.append(_d) + return _d + if not have_pytube: return None try: @@ -2660,7 +2671,7 @@ def force_ntsc_config(ps3config): snd0 = 'https://www.youtube.com/watch?v=' + a.results[0].video_id print('Found Youtube link', 'https://www.youtube.com/watch?v=' + a.results[0].video_id) if snd0 and snd0[:24] == 'https://www.youtube.com/': - snd0 = get_snd0_from_link(snd0) + snd0 = get_snd0_from_link(snd0, subdir=subdir) if snd0: temp_files.append(snd0)