fixed the bitrange

This commit is contained in:
Hellow 2023-09-11 21:34:45 +02:00
parent 151cdf7831
commit 7758b82312
4 changed files with 12 additions and 12 deletions

View File

@ -3,6 +3,7 @@ import logging
import gc
import musicbrainzngs
from .utils.shared import DEBUG
from .utils.config import logging_settings, main_settings, read_config
read_config()
from . import cli
@ -10,7 +11,7 @@ from . import cli
# configure logger default
logging.basicConfig(
level=logging_settings['log_level'],
level=logging_settings['log_level'] if not DEBUG else logging.DEBUG,
format=logging_settings['logging_format'],
handlers=[
logging.FileHandler(main_settings['log_file']),

View File

@ -4,6 +4,7 @@ from typing import Optional, Dict, Tuple, List
from .metadata import Metadata
from .option import Options
from ..utils.shared import HIGHEST_ID
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
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
LOGGER.debug(f"Id for {type(self).__name__} isn't set. Setting to {_id}")

View File

@ -5,11 +5,10 @@ import random
import json
from dataclasses import dataclass
import re
import requests
from ...utils.exception.config import SettingValueError
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
if DEBUG:
from ...utils.debug_utils import dump_to_file
@ -109,7 +108,7 @@ class YoutubeMusic(SuperYouTube):
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()
super().__init__(*args, **kwargs)
@ -218,6 +217,7 @@ class YoutubeMusic(SuperYouTube):
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)
_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)

View File

@ -1,14 +1,9 @@
import logging
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, logging_settings, youtube_settings
from .enums.album import AlbumType
from .config import main_settings
DEBUG = True
DEBUG_YOUTUBE_INITILIZING = DEBUG and False
if DEBUG:
print("DEBUG ACTIVE")
@ -16,6 +11,9 @@ def get_random_message() -> str:
return random.choice(main_settings['happy_messages'])
HIGHEST_ID = 2**main_settings['id_bits']
HELP_MESSAGE = """
to search:
> s: {query or url}