Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| a620c16b1c | |||
| cf27ae098d | |||
| a0c60a473a | |||
| 25c5a4d175 | |||
| 33a6137f75 |
@@ -6,7 +6,7 @@
|
|||||||
<b>SpotiFLAC</b> allows you to download Spotify tracks in true FLAC format through services like Tidal & Deezer.
|
<b>SpotiFLAC</b> allows you to download Spotify tracks in true FLAC format through services like Tidal & Deezer.
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
### [Download](https://github.com/afkarxyz/SpotiFLAC/releases/download/v5.0/SpotiFLAC.exe)
|
### [Download](https://github.com/afkarxyz/SpotiFLAC/releases/download/v5.2/SpotiFLAC.exe)
|
||||||
|
|
||||||
## Screenshots
|
## Screenshots
|
||||||
|
|
||||||
@@ -16,7 +16,7 @@
|
|||||||
|
|
||||||

|

|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
## Lossless Audio Check
|
## Lossless Audio Check
|
||||||
|
|
||||||
|
|||||||
+24
-22
@@ -157,10 +157,12 @@ class DownloadWorker(QThread):
|
|||||||
if self.use_artist_subfolders:
|
if self.use_artist_subfolders:
|
||||||
artist_name = track.artists.split(', ')[0] if ', ' in track.artists else track.artists
|
artist_name = track.artists.split(', ')[0] if ', ' in track.artists else track.artists
|
||||||
artist_folder = re.sub(r'[<>:"/\\|?*]', lambda m: "'" if m.group() == '"' else '_', artist_name)
|
artist_folder = re.sub(r'[<>:"/\\|?*]', lambda m: "'" if m.group() == '"' else '_', artist_name)
|
||||||
|
artist_folder = artist_folder.rstrip('. ')
|
||||||
track_outpath = os.path.join(track_outpath, artist_folder)
|
track_outpath = os.path.join(track_outpath, artist_folder)
|
||||||
|
|
||||||
if self.use_album_subfolders:
|
if self.use_album_subfolders:
|
||||||
album_folder = re.sub(r'[<>:"/\\|?*]', lambda m: "'" if m.group() == '"' else '_', track.album)
|
album_folder = re.sub(r'[<>:"/\\|?*]', lambda m: "'" if m.group() == '"' else '_', track.album)
|
||||||
|
album_folder = album_folder.rstrip('. ')
|
||||||
track_outpath = os.path.join(track_outpath, album_folder)
|
track_outpath = os.path.join(track_outpath, album_folder)
|
||||||
|
|
||||||
os.makedirs(track_outpath, exist_ok=True)
|
os.makedirs(track_outpath, exist_ok=True)
|
||||||
@@ -213,13 +215,16 @@ class DownloadWorker(QThread):
|
|||||||
is_paused_callback = lambda: self.is_paused
|
is_paused_callback = lambda: self.is_paused
|
||||||
is_stopped_callback = lambda: self.is_stopped
|
is_stopped_callback = lambda: self.is_stopped
|
||||||
|
|
||||||
|
auto_fallback = (self.tidal_api_url == "auto")
|
||||||
|
|
||||||
download_result_details = downloader.download(
|
download_result_details = downloader.download(
|
||||||
query=f"{track.title} {track.artists}",
|
query=f"{track.title} {track.artists}",
|
||||||
isrc=track.isrc,
|
isrc=track.isrc,
|
||||||
output_dir=track_outpath,
|
output_dir=track_outpath,
|
||||||
quality="LOSSLESS",
|
quality="LOSSLESS",
|
||||||
is_paused_callback=is_paused_callback,
|
is_paused_callback=is_paused_callback,
|
||||||
is_stopped_callback=is_stopped_callback
|
is_stopped_callback=is_stopped_callback,
|
||||||
|
auto_fallback=auto_fallback
|
||||||
)
|
)
|
||||||
|
|
||||||
if isinstance(download_result_details, str) and os.path.exists(download_result_details):
|
if isinstance(download_result_details, str) and os.path.exists(download_result_details):
|
||||||
@@ -391,7 +396,7 @@ class ServiceStatusDelegate(QStyledItemDelegate):
|
|||||||
|
|
||||||
class TidalAPIDelegate(QStyledItemDelegate):
|
class TidalAPIDelegate(QStyledItemDelegate):
|
||||||
def paint(self, painter, option, index):
|
def paint(self, painter, option, index):
|
||||||
item_data = index.data(Qt.ItemDataRole.UserRole)
|
item_data = index.data(Qt.ItemDataRole.UserRole + 1)
|
||||||
|
|
||||||
super().paint(painter, option, index)
|
super().paint(painter, option, index)
|
||||||
|
|
||||||
@@ -532,7 +537,7 @@ class ServiceComboBox(QComboBox):
|
|||||||
class SpotiFLACGUI(QWidget):
|
class SpotiFLACGUI(QWidget):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.current_version = "5.1"
|
self.current_version = "5.3"
|
||||||
self.tracks = []
|
self.tracks = []
|
||||||
self.all_tracks = []
|
self.all_tracks = []
|
||||||
self.successful_downloads = []
|
self.successful_downloads = []
|
||||||
@@ -1138,23 +1143,23 @@ class SpotiFLACGUI(QWidget):
|
|||||||
service_api_layout = QHBoxLayout()
|
service_api_layout = QHBoxLayout()
|
||||||
|
|
||||||
service_label = QLabel('Service:')
|
service_label = QLabel('Service:')
|
||||||
service_label.setFixedWidth(60)
|
service_label.setFixedWidth(53)
|
||||||
|
|
||||||
self.service_dropdown = ServiceComboBox()
|
self.service_dropdown = ServiceComboBox()
|
||||||
self.service_dropdown.setFixedWidth(120)
|
self.service_dropdown.setFixedWidth(100)
|
||||||
self.service_dropdown.currentIndexChanged.connect(self.on_service_changed)
|
self.service_dropdown.currentIndexChanged.connect(self.on_service_changed)
|
||||||
|
|
||||||
service_api_layout.addWidget(service_label)
|
service_api_layout.addWidget(service_label)
|
||||||
service_api_layout.addWidget(self.service_dropdown)
|
service_api_layout.addWidget(self.service_dropdown)
|
||||||
service_api_layout.addSpacing(15)
|
service_api_layout.addSpacing(15)
|
||||||
|
|
||||||
self.tidal_api_label = QLabel('Tidal API:')
|
self.tidal_api_label = QLabel('API Instances:')
|
||||||
self.tidal_api_label.setFixedWidth(70)
|
self.tidal_api_label.setFixedWidth(85)
|
||||||
|
|
||||||
self.tidal_api_dropdown = QComboBox()
|
self.tidal_api_dropdown = QComboBox()
|
||||||
self.tidal_api_dropdown.setItemDelegate(TidalAPIDelegate())
|
self.tidal_api_dropdown.setItemDelegate(TidalAPIDelegate())
|
||||||
self.tidal_api_dropdown.addItem("Default (401658)", "https://hifi.401658.xyz")
|
self.tidal_api_dropdown.addItem("Default", "https://hifi.401658.xyz")
|
||||||
self.tidal_api_dropdown.addItem("Auto-select fastest", "auto")
|
self.tidal_api_dropdown.addItem("Auto Fallback", "auto")
|
||||||
self.tidal_api_dropdown.currentIndexChanged.connect(self.on_tidal_api_changed)
|
self.tidal_api_dropdown.currentIndexChanged.connect(self.on_tidal_api_changed)
|
||||||
|
|
||||||
self.refresh_api_btn = QPushButton('Refresh')
|
self.refresh_api_btn = QPushButton('Refresh')
|
||||||
@@ -1163,10 +1168,9 @@ class SpotiFLACGUI(QWidget):
|
|||||||
self.refresh_api_btn.clicked.connect(self.refresh_tidal_apis)
|
self.refresh_api_btn.clicked.connect(self.refresh_tidal_apis)
|
||||||
|
|
||||||
service_api_layout.addWidget(self.tidal_api_label)
|
service_api_layout.addWidget(self.tidal_api_label)
|
||||||
service_api_layout.addWidget(self.tidal_api_dropdown)
|
service_api_layout.addWidget(self.tidal_api_dropdown, 1)
|
||||||
service_api_layout.addSpacing(5)
|
service_api_layout.addSpacing(5)
|
||||||
service_api_layout.addWidget(self.refresh_api_btn)
|
service_api_layout.addWidget(self.refresh_api_btn)
|
||||||
service_api_layout.addStretch()
|
|
||||||
|
|
||||||
auth_layout.addLayout(service_api_layout)
|
auth_layout.addLayout(service_api_layout)
|
||||||
|
|
||||||
@@ -1430,11 +1434,11 @@ class SpotiFLACGUI(QWidget):
|
|||||||
self.tidal_api = selected_api
|
self.tidal_api = selected_api
|
||||||
self.settings.setValue('tidal_api', selected_api)
|
self.settings.setValue('tidal_api', selected_api)
|
||||||
self.settings.sync()
|
self.settings.sync()
|
||||||
self.log_output.append(f"Tidal API changed to: {self.tidal_api_dropdown.currentText()}")
|
self.log_output.append(f"API Instance changed to: {self.tidal_api_dropdown.currentText()}")
|
||||||
|
|
||||||
def refresh_tidal_apis(self):
|
def refresh_tidal_apis(self):
|
||||||
try:
|
try:
|
||||||
self.log_output.append("Fetching available Tidal APIs...")
|
self.log_output.append("Fetching available API instances...")
|
||||||
apis = TidalDownloader.get_available_apis()
|
apis = TidalDownloader.get_available_apis()
|
||||||
|
|
||||||
while self.tidal_api_dropdown.count() > 2:
|
while self.tidal_api_dropdown.count() > 2:
|
||||||
@@ -1458,9 +1462,9 @@ class SpotiFLACGUI(QWidget):
|
|||||||
|
|
||||||
self.tidal_api_dropdown.addItem(label, url)
|
self.tidal_api_dropdown.addItem(label, url)
|
||||||
item_index = self.tidal_api_dropdown.count() - 1
|
item_index = self.tidal_api_dropdown.count() - 1
|
||||||
self.tidal_api_dropdown.setItemData(item_index, status_data, Qt.ItemDataRole.UserRole)
|
self.tidal_api_dropdown.setItemData(item_index, status_data, Qt.ItemDataRole.UserRole + 1)
|
||||||
|
|
||||||
self.log_output.append(f"Found {len(apis)} available Tidal APIs")
|
self.log_output.append(f"Found {len(apis)} available API instances")
|
||||||
else:
|
else:
|
||||||
self.log_output.append("No APIs found, using default")
|
self.log_output.append("No APIs found, using default")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
@@ -1911,6 +1915,7 @@ class SpotiFLACGUI(QWidget):
|
|||||||
if self.is_album or self.is_playlist:
|
if self.is_album or self.is_playlist:
|
||||||
name = self.album_or_playlist_name.strip()
|
name = self.album_or_playlist_name.strip()
|
||||||
folder_name = re.sub(r'[<>:"/\\|?*]', '_', name)
|
folder_name = re.sub(r'[<>:"/\\|?*]', '_', name)
|
||||||
|
folder_name = folder_name.rstrip('. ')
|
||||||
outpath = os.path.join(outpath, folder_name)
|
outpath = os.path.join(outpath, folder_name)
|
||||||
os.makedirs(outpath, exist_ok=True)
|
os.makedirs(outpath, exist_ok=True)
|
||||||
|
|
||||||
@@ -1926,15 +1931,11 @@ class SpotiFLACGUI(QWidget):
|
|||||||
if service == "tidal":
|
if service == "tidal":
|
||||||
selected_api = self.tidal_api_dropdown.currentData()
|
selected_api = self.tidal_api_dropdown.currentData()
|
||||||
if selected_api == "auto":
|
if selected_api == "auto":
|
||||||
apis = TidalDownloader.get_available_apis()
|
tidal_api_url = "auto"
|
||||||
if apis:
|
self.log_output.append("Using auto fallback mode (will try multiple APIs)")
|
||||||
tidal_api_url = apis[0]['url']
|
|
||||||
self.log_output.append(f"Auto-selected fastest API: {tidal_api_url}")
|
|
||||||
else:
|
|
||||||
tidal_api_url = "https://hifi.401658.xyz"
|
|
||||||
self.log_output.append("Using default API: https://hifi.401658.xyz")
|
|
||||||
else:
|
else:
|
||||||
tidal_api_url = selected_api
|
tidal_api_url = selected_api
|
||||||
|
self.log_output.append(f"Using API: {selected_api}")
|
||||||
|
|
||||||
self.worker = DownloadWorker(
|
self.worker = DownloadWorker(
|
||||||
tracks_to_download,
|
tracks_to_download,
|
||||||
@@ -1966,6 +1967,7 @@ class SpotiFLACGUI(QWidget):
|
|||||||
|
|
||||||
self.stop_btn.show()
|
self.stop_btn.show()
|
||||||
self.pause_resume_btn.show()
|
self.pause_resume_btn.show()
|
||||||
|
self.remove_successful_btn.hide()
|
||||||
self.progress_bar.show()
|
self.progress_bar.show()
|
||||||
self.progress_bar.setValue(0)
|
self.progress_bar.setValue(0)
|
||||||
|
|
||||||
|
|||||||
+40
-3
@@ -57,7 +57,7 @@ class TidalDownloader:
|
|||||||
print("No APIs available, using default: https://hifi.401658.xyz")
|
print("No APIs available, using default: https://hifi.401658.xyz")
|
||||||
return "https://hifi.401658.xyz"
|
return "https://hifi.401658.xyz"
|
||||||
|
|
||||||
print("\n=== Available Tidal APIs ===")
|
print("\n=== Available API Instances ===")
|
||||||
print(f"{'No':<4} {'URL':<40} {'Status':<8} {'Uptime':<8} {'Avg Response':<12}")
|
print(f"{'No':<4} {'URL':<40} {'Status':<8} {'Uptime':<8} {'Avg Response':<12}")
|
||||||
print("-" * 80)
|
print("-" * 80)
|
||||||
|
|
||||||
@@ -253,6 +253,10 @@ class TidalDownloader:
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
def download_file(self, url, filepath, is_paused_callback=None, is_stopped_callback=None):
|
def download_file(self, url, filepath, is_paused_callback=None, is_stopped_callback=None):
|
||||||
|
file_dir = os.path.dirname(filepath)
|
||||||
|
if file_dir and not os.path.exists(file_dir):
|
||||||
|
os.makedirs(file_dir, exist_ok=True)
|
||||||
|
|
||||||
temp_filepath = filepath + ".part"
|
temp_filepath = filepath + ".part"
|
||||||
retry_count = 0
|
retry_count = 0
|
||||||
|
|
||||||
@@ -385,13 +389,46 @@ class TidalDownloader:
|
|||||||
print(f"Error embedding metadata: {str(e)}")
|
print(f"Error embedding metadata: {str(e)}")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def download(self, query, isrc=None, output_dir=".", quality="LOSSLESS", is_paused_callback=None, is_stopped_callback=None):
|
def download(self, query, isrc=None, output_dir=".", quality="LOSSLESS", is_paused_callback=None, is_stopped_callback=None, auto_fallback=False):
|
||||||
if output_dir != ".":
|
if output_dir != ".":
|
||||||
try:
|
try:
|
||||||
os.makedirs(output_dir, exist_ok=True)
|
os.makedirs(output_dir, exist_ok=True)
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
raise Exception(f"Directory error: {e}")
|
raise Exception(f"Directory error: {e}")
|
||||||
|
|
||||||
|
if auto_fallback:
|
||||||
|
apis = self.get_available_apis()
|
||||||
|
if not apis:
|
||||||
|
print("No APIs available for fallback, using current API")
|
||||||
|
return self._download_single(query, isrc, output_dir, quality, is_paused_callback, is_stopped_callback)
|
||||||
|
|
||||||
|
last_error = None
|
||||||
|
for i, api in enumerate(apis, 1):
|
||||||
|
api_url = api.get('url')
|
||||||
|
try:
|
||||||
|
print(f"[Auto Fallback {i}/{len(apis)}] Trying: {api_url}")
|
||||||
|
|
||||||
|
fallback_downloader = TidalDownloader(api_url=api_url)
|
||||||
|
fallback_downloader.set_progress_callback(self.progress_callback)
|
||||||
|
|
||||||
|
result = fallback_downloader._download_single(
|
||||||
|
query, isrc, output_dir, quality,
|
||||||
|
is_paused_callback, is_stopped_callback
|
||||||
|
)
|
||||||
|
|
||||||
|
print(f"✓ Success with: {api_url}")
|
||||||
|
return result
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
last_error = str(e)
|
||||||
|
print(f"✗ Failed with {api_url}: {last_error[:80]}")
|
||||||
|
continue
|
||||||
|
|
||||||
|
raise Exception(f"All {len(apis)} APIs failed. Last error: {last_error}")
|
||||||
|
|
||||||
|
return self._download_single(query, isrc, output_dir, quality, is_paused_callback, is_stopped_callback)
|
||||||
|
|
||||||
|
def _download_single(self, query, isrc, output_dir, quality, is_paused_callback, is_stopped_callback):
|
||||||
track_info = self.get_track_info(query, isrc)
|
track_info = self.get_track_info(query, isrc)
|
||||||
track_id = track_info.get("id")
|
track_id = track_info.get("id")
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -1,3 +1,3 @@
|
|||||||
{
|
{
|
||||||
"version": "5.0"
|
"version": "5.2"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user