| 971 | opj = os.path.join |
| 972 | opj = os.path.join |
| 973 | def look_for_music(path): |
| 974 | files = [p for p in os.listdir(path) if not p.startswith('.') and not os.path.isdir(opj(path, p))] |
| 975 | for f in files: |
| 976 | ext = f.lower()[-3:] |
| 977 | if ext in ['wav', 'ogg', 'mp3', 'aac', 'mp2', 'ac3', 'm4a'] and not ext in ('wav'): |
| 978 | return [opj(path, f)] |
| 979 | dirs = [opj(path, p) for p in os.listdir(path) if not p.startswith('.') and os.path.isdir(opj(path, p))] |
| 980 | results = [] |
| 981 | for d in dirs: |
| 982 | results.extend(look_for_music(d)) |
| 983 | if results: return results |
| 984 | return results |
| 985 | music_file = look_for_music(res_path) |
| 986 | if music_file: |
| 987 | # The first time we load a file should trigger the exception |