Skip to content

Commit

Permalink
Pull snd0 from github cache if available
Browse files Browse the repository at this point in the history
Signed-off-by: Ronnie Sahlberg <[email protected]>
  • Loading branch information
sahlberg committed Nov 19, 2023
1 parent 028db64 commit af7db1e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pop-fe-ps3.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion pop-fe-psp.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
13 changes: 12 additions & 1 deletion pop-fe.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit af7db1e

Please sign in to comment.