fixed the bitrange
This commit is contained in:
parent
151cdf7831
commit
7758b82312
@ -3,6 +3,7 @@ import logging
|
|||||||
import gc
|
import gc
|
||||||
import musicbrainzngs
|
import musicbrainzngs
|
||||||
|
|
||||||
|
from .utils.shared import DEBUG
|
||||||
from .utils.config import logging_settings, main_settings, read_config
|
from .utils.config import logging_settings, main_settings, read_config
|
||||||
read_config()
|
read_config()
|
||||||
from . import cli
|
from . import cli
|
||||||
@ -10,7 +11,7 @@ from . import cli
|
|||||||
|
|
||||||
# configure logger default
|
# configure logger default
|
||||||
logging.basicConfig(
|
logging.basicConfig(
|
||||||
level=logging_settings['log_level'],
|
level=logging_settings['log_level'] if not DEBUG else logging.DEBUG,
|
||||||
format=logging_settings['logging_format'],
|
format=logging_settings['logging_format'],
|
||||||
handlers=[
|
handlers=[
|
||||||
logging.FileHandler(main_settings['log_file']),
|
logging.FileHandler(main_settings['log_file']),
|
||||||
|
@ -4,6 +4,7 @@ from typing import Optional, Dict, Tuple, List
|
|||||||
|
|
||||||
from .metadata import Metadata
|
from .metadata import Metadata
|
||||||
from .option import Options
|
from .option import Options
|
||||||
|
from ..utils.shared import HIGHEST_ID
|
||||||
from ..utils.config import main_settings, logging_settings
|
from ..utils.config import main_settings, logging_settings
|
||||||
|
|
||||||
|
|
||||||
@ -28,7 +29,7 @@ class DatabaseObject:
|
|||||||
64 bit integer, but this is defined in shared.py in ID_BITS
|
64 bit integer, but this is defined in shared.py in ID_BITS
|
||||||
the range is defined in the Tuple ID_RANGE
|
the range is defined in the Tuple ID_RANGE
|
||||||
"""
|
"""
|
||||||
_id = random.randint(0, main_settings['id_bits'])
|
_id = random.randint(0, HIGHEST_ID)
|
||||||
self.automatic_id = True
|
self.automatic_id = True
|
||||||
LOGGER.debug(f"Id for {type(self).__name__} isn't set. Setting to {_id}")
|
LOGGER.debug(f"Id for {type(self).__name__} isn't set. Setting to {_id}")
|
||||||
|
|
||||||
|
@ -5,11 +5,10 @@ import random
|
|||||||
import json
|
import json
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
import re
|
import re
|
||||||
import requests
|
|
||||||
|
|
||||||
from ...utils.exception.config import SettingValueError
|
from ...utils.exception.config import SettingValueError
|
||||||
from ...utils.config import main_settings, youtube_settings, logging_settings
|
from ...utils.config import main_settings, youtube_settings, logging_settings
|
||||||
from ...utils.shared import DEBUG
|
from ...utils.shared import DEBUG, DEBUG_YOUTUBE_INITILIZING
|
||||||
from ...utils.functions import get_current_millis
|
from ...utils.functions import get_current_millis
|
||||||
if DEBUG:
|
if DEBUG:
|
||||||
from ...utils.debug_utils import dump_to_file
|
from ...utils.debug_utils import dump_to_file
|
||||||
@ -109,7 +108,7 @@ class YoutubeMusic(SuperYouTube):
|
|||||||
|
|
||||||
self.start_millis = get_current_millis()
|
self.start_millis = get_current_millis()
|
||||||
|
|
||||||
if self.credentials.api_key == "" or DEBUG:
|
if self.credentials.api_key == "" or DEBUG_YOUTUBE_INITILIZING:
|
||||||
self._fetch_from_main_page()
|
self._fetch_from_main_page()
|
||||||
|
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
@ -218,6 +217,7 @@ class YoutubeMusic(SuperYouTube):
|
|||||||
|
|
||||||
urlescaped_query: str = quote(search_query.strip().replace(" ", "+"))
|
urlescaped_query: str = quote(search_query.strip().replace(" ", "+"))
|
||||||
|
|
||||||
|
# approximate the ammount of time it would take to type the search, because google for some reason tracks that
|
||||||
LAST_EDITED_TIME = get_current_millis() - random.randint(0, 20)
|
LAST_EDITED_TIME = get_current_millis() - random.randint(0, 20)
|
||||||
_estimated_time = sum(len(search_query) * random.randint(50, 100) for _ in search_query.strip())
|
_estimated_time = sum(len(search_query) * random.randint(50, 100) for _ in search_query.strip())
|
||||||
FIRST_EDITED_TIME = LAST_EDITED_TIME - _estimated_time if LAST_EDITED_TIME - self.start_millis > _estimated_time else random.randint(50, 100)
|
FIRST_EDITED_TIME = LAST_EDITED_TIME - _estimated_time if LAST_EDITED_TIME - self.start_millis > _estimated_time else random.randint(50, 100)
|
||||||
|
@ -1,14 +1,9 @@
|
|||||||
import logging
|
|
||||||
import random
|
import random
|
||||||
from pathlib import Path
|
|
||||||
from typing import List, Tuple, Set, Dict
|
|
||||||
from urllib.parse import ParseResult
|
|
||||||
|
|
||||||
from .path_manager import LOCATIONS
|
from .config import main_settings
|
||||||
from .config import main_settings, logging_settings, youtube_settings
|
|
||||||
from .enums.album import AlbumType
|
|
||||||
|
|
||||||
DEBUG = True
|
DEBUG = True
|
||||||
|
DEBUG_YOUTUBE_INITILIZING = DEBUG and False
|
||||||
if DEBUG:
|
if DEBUG:
|
||||||
print("DEBUG ACTIVE")
|
print("DEBUG ACTIVE")
|
||||||
|
|
||||||
@ -16,6 +11,9 @@ def get_random_message() -> str:
|
|||||||
return random.choice(main_settings['happy_messages'])
|
return random.choice(main_settings['happy_messages'])
|
||||||
|
|
||||||
|
|
||||||
|
HIGHEST_ID = 2**main_settings['id_bits']
|
||||||
|
|
||||||
|
|
||||||
HELP_MESSAGE = """
|
HELP_MESSAGE = """
|
||||||
to search:
|
to search:
|
||||||
> s: {query or url}
|
> s: {query or url}
|
||||||
|
Loading…
Reference in New Issue
Block a user