Big Debug of PMOQobuz step 3
This commit is contained in:
53
pmoqobuz/test_python_qobuz/patch_for_fake.py
Executable file
53
pmoqobuz/test_python_qobuz/patch_for_fake.py
Executable file
@@ -0,0 +1,53 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Patch raw.py to use fake server
|
||||
"""
|
||||
|
||||
import sys
|
||||
|
||||
def patch_raw_py():
|
||||
"""Replace base URL in raw.py"""
|
||||
with open('raw.py', 'r') as f:
|
||||
content = f.read()
|
||||
|
||||
# Replace base URL (without version, as it's constructed dynamically)
|
||||
original_line = 'self.baseUrl = "https://www.qobuz.com/api.json/"'
|
||||
fake_line = 'self.baseUrl = "http://localhost:8080/api.json/"'
|
||||
|
||||
if original_line in content:
|
||||
content = content.replace(original_line, fake_line)
|
||||
with open('raw.py', 'w') as f:
|
||||
f.write(content)
|
||||
print(f"✓ Patched raw.py:")
|
||||
print(f" {original_line}")
|
||||
print(f" → {fake_line}")
|
||||
return True
|
||||
else:
|
||||
print("✗ Original URL not found in raw.py")
|
||||
print(" Looking for:", original_line)
|
||||
return False
|
||||
|
||||
def unpatch_raw_py():
|
||||
"""Restore original URL in raw.py"""
|
||||
with open('raw.py', 'r') as f:
|
||||
content = f.read()
|
||||
|
||||
original_line = 'self.baseUrl = "https://www.qobuz.com/api.json/"'
|
||||
fake_line = 'self.baseUrl = "http://localhost:8080/api.json/"'
|
||||
|
||||
if fake_line in content:
|
||||
content = content.replace(fake_line, original_line)
|
||||
with open('raw.py', 'w') as f:
|
||||
f.write(content)
|
||||
print(f"✓ Restored raw.py to original URL")
|
||||
return True
|
||||
else:
|
||||
print("✗ Fake URL not found in raw.py (already restored?)")
|
||||
return False
|
||||
|
||||
if __name__ == "__main__":
|
||||
if len(sys.argv) > 1 and sys.argv[1] == "restore":
|
||||
unpatch_raw_py()
|
||||
else:
|
||||
patch_raw_py()
|
||||
print("\nTo restore: python3 patch_for_fake.py restore")
|
||||
Reference in New Issue
Block a user