mirror of
https://github.com/nathom/streamrip.git
synced 2025-05-15 07:34:48 -04:00
Formatting
This commit is contained in:
parent
3414fa21a9
commit
60e1f05115
2 changed files with 11 additions and 12 deletions
|
@ -14,7 +14,7 @@ from .constants import CACHE_DIR, CONFIG_DIR, CONFIG_PATH, QOBUZ_FEATURED_KEYS
|
||||||
from .core import MusicDL
|
from .core import MusicDL
|
||||||
from .utils import init_log
|
from .utils import init_log
|
||||||
|
|
||||||
logging.basicConfig(level="INFO")
|
logging.basicConfig(level="WARNING")
|
||||||
logger = logging.getLogger("streamrip")
|
logger = logging.getLogger("streamrip")
|
||||||
|
|
||||||
if not os.path.isdir(CONFIG_DIR):
|
if not os.path.isdir(CONFIG_DIR):
|
||||||
|
|
|
@ -6,10 +6,8 @@ import logging
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
import time
|
|
||||||
from getpass import getpass
|
from getpass import getpass
|
||||||
from hashlib import md5
|
from hashlib import md5
|
||||||
from pprint import pprint
|
|
||||||
from string import Formatter
|
from string import Formatter
|
||||||
from typing import Dict, Generator, List, Optional, Tuple, Type, Union
|
from typing import Dict, Generator, List, Optional, Tuple, Type, Union
|
||||||
|
|
||||||
|
@ -225,7 +223,6 @@ class MusicDL(list):
|
||||||
|
|
||||||
source_subdirs = self.config.session["downloads"]["source_subdirectories"]
|
source_subdirs = self.config.session["downloads"]["source_subdirectories"]
|
||||||
for item in self:
|
for item in self:
|
||||||
|
|
||||||
if source_subdirs:
|
if source_subdirs:
|
||||||
arguments["parent_folder"] = self.__get_source_subdir(
|
arguments["parent_folder"] = self.__get_source_subdir(
|
||||||
item.client.source
|
item.client.source
|
||||||
|
@ -244,6 +241,7 @@ class MusicDL(list):
|
||||||
logger.debug("Added filter argument for artist/label: %s", filters_)
|
logger.debug("Added filter argument for artist/label: %s", filters_)
|
||||||
|
|
||||||
if not (isinstance(item, Tracklist) and item.loaded):
|
if not (isinstance(item, Tracklist) and item.loaded):
|
||||||
|
logger.debug("Loading metadata")
|
||||||
try:
|
try:
|
||||||
item.load_meta()
|
item.load_meta()
|
||||||
except NonStreamable:
|
except NonStreamable:
|
||||||
|
@ -450,7 +448,6 @@ class MusicDL(list):
|
||||||
:type limit: int
|
:type limit: int
|
||||||
:rtype: Generator
|
:rtype: Generator
|
||||||
"""
|
"""
|
||||||
print(logger)
|
|
||||||
logger.debug("searching for %s", query)
|
logger.debug("searching for %s", query)
|
||||||
|
|
||||||
client = self.get_client(source)
|
client = self.get_client(source)
|
||||||
|
@ -474,9 +471,9 @@ class MusicDL(list):
|
||||||
items = (
|
items = (
|
||||||
results.get("data") or results.get("items") or results.get("collection")
|
results.get("data") or results.get("items") or results.get("collection")
|
||||||
)
|
)
|
||||||
logger.debug("Number of results: %d", len(items))
|
|
||||||
if items is None:
|
if items is None:
|
||||||
raise NoResultsFound(query)
|
raise NoResultsFound(query)
|
||||||
|
logger.debug("Number of results: %d", len(items))
|
||||||
|
|
||||||
for i, item in enumerate(items):
|
for i, item in enumerate(items):
|
||||||
logger.debug(item["title"])
|
logger.debug(item["title"])
|
||||||
|
@ -637,19 +634,21 @@ class MusicDL(list):
|
||||||
remaining_tracks_match = re.search(
|
remaining_tracks_match = re.search(
|
||||||
r'data-playlisting-entry-count="(\d+)"', r.text
|
r'data-playlisting-entry-count="(\d+)"', r.text
|
||||||
)
|
)
|
||||||
if remaining_tracks_match is not None:
|
if remaining_tracks_match is None:
|
||||||
remaining_tracks = int(remaining_tracks_match.group(1)) - 50
|
|
||||||
else:
|
|
||||||
raise ParsingError("Error parsing lastfm page: %s", r.text)
|
raise ParsingError("Error parsing lastfm page: %s", r.text)
|
||||||
|
|
||||||
|
total_tracks = int(remaining_tracks_match.group(1))
|
||||||
|
logger.debug("Total tracks: %d", total_tracks)
|
||||||
|
remaining_tracks = total_tracks - 50
|
||||||
|
|
||||||
playlist_title_match = re.search(
|
playlist_title_match = re.search(
|
||||||
r'<h1 class="playlisting-playlist-header-title">([^<]+)</h1>', r.text
|
r'<h1 class="playlisting-playlist-header-title">([^<]+)</h1>', r.text
|
||||||
)
|
)
|
||||||
if playlist_title_match is not None:
|
if playlist_title_match is None:
|
||||||
playlist_title = html.unescape(playlist_title_match.group(1))
|
|
||||||
else:
|
|
||||||
raise ParsingError("Error finding title from response")
|
raise ParsingError("Error finding title from response")
|
||||||
|
|
||||||
|
playlist_title = html.unescape(playlist_title_match.group(1))
|
||||||
|
|
||||||
if remaining_tracks > 0:
|
if remaining_tracks > 0:
|
||||||
with concurrent.futures.ThreadPoolExecutor(max_workers=15) as executor:
|
with concurrent.futures.ThreadPoolExecutor(max_workers=15) as executor:
|
||||||
last_page = int(remaining_tracks // 50) + int(
|
last_page = int(remaining_tracks // 50) + int(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue