"""Fetch the small, pinned CC0 sample subset used by the acoustic arrangement.""" from pathlib import Path import urllib.request, urllib.parse, json, hashlib, concurrent.futures DEST = Path(__file__).resolve().parent / 'SourceSamples~' REV = '440300901dfe9275fd84e0b7763af1f8443ae62e' ITEMS = [ ('piano_c3.wav','Keys/Upright Nr1/UR1_C3_mf_RR1.wav',48), ('piano_c4.wav','Keys/Upright Nr1/UR1_C4_mf_RR1.wav',60), ('piano_g4.wav','Keys/Upright Nr1/UR1_G4_mf_RR1.wav',67), ('clarinet_bb3.wav','Woodwinds/Clarinet/stac/DCClar_stac_A#3_v1_rr1_sum.wav',70), ('flute_c4.wav','Woodwinds/Flute/stac/LDFlute_stac_C4_v1_rr1.wav',72), ('flute_a3.wav','Woodwinds/Flute/stac/LDFlute_stac_A3_v1_rr1.wav',69), ('pizz_c4.wav','Strings/Violin Section/Pizz/VlnEns_Pizz_C4_v1_rr1.wav',72), ('marimba_f3.wav','Percussion/Marimba/Marimba_hit_Outrigger_F3_loud_01.wav',65), ('marimba_c4.wav','Percussion/Marimba/Marimba_hit_Outrigger_C4_loud_01.wav',72), ('marimba_g4.wav','Percussion/Marimba/Marimba_hit_Outrigger_G4_loud_01.wav',79), ('marimba_b4.wav','Percussion/Marimba/Marimba_hit_Outrigger_B4_loud_01.wav',83), ('harp_c3.wav','Strings/Harp/KSHarp_C3_mf.wav',48), ('harp_c5.wav','Strings/Harp/KSHarp_C5_mf.wav',72), ('harp_g3.wav','Strings/Harp/KSHarp_G3_mf.wav',55), ('bass_d1.wav','Strings/Solo Contrabass/Pizz/BKCtbss_Pizz_D1_v1_rr1.wav',38), ('wood.wav','VSCO 1 Percussion/varWood/wood_click_pp_1.wav',None), ('shaker.wav',"VSCO 1 Percussion/varWood/Camo's Shaker/shake1.wav",None), ('conga.wav','Percussion/Conga-Tap1_v1_rr1_Sum.wav',None), ] def fetch(item): name, path, midi = item url = 'https://raw.githubusercontent.com/sgossner/VSCO-2-CE/'+REV+'/'+urllib.parse.quote(path) destination = DEST/name if not destination.exists(): for attempt in range(3): try: data = urllib.request.urlopen(url, timeout=30).read() destination.write_bytes(data) break except Exception: if attempt == 2: raise data = destination.read_bytes() return dict(file=name, source=path, url=url, midi=midi, sha256=hashlib.sha256(data).hexdigest(), bytes=len(data)) if __name__ == '__main__': DEST.mkdir(exist_ok=True) with concurrent.futures.ThreadPoolExecutor(max_workers=4) as pool: records = list(pool.map(fetch, ITEMS)) for name in ['LICENSE', 'Readme.txt']: fetch((name, name, None)) manifest = dict(library='VSCO 2 Community Edition', revision=REV, license='CC0-1.0', credit='Versilian Studios / Sam Gossner; Ivy Audio / Simon Dalzell; sample cutting Elan Hickler / Soundemote', files=records) (DEST/'sources.json').write_text(json.dumps(manifest, indent=2)+'\n', encoding='utf-8') print([(x['file'], x['bytes']) for x in records])