progress on threading

This commit is contained in:
Hellow2
2023-05-25 13:46:47 +02:00
parent 1362f708e6
commit 6caa6a28a6
6 changed files with 15 additions and 11 deletions

View File

@@ -3,6 +3,7 @@ import random
from copy import copy
from typing import Optional, Union, Type, Dict, Set, List
import threading
from queue import Queue
import requests
from bs4 import BeautifulSoup
@@ -108,11 +109,14 @@ class Page(threading.Thread):
This is an abstract class, laying out the
functionality for every other class fetching something
"""
SOURCE_TYPE: SourcePages
LOGGER = logging.getLogger("this shouldn't be used")
def __init__(self):
def __init__(self, search_queue: Queue, search_result_queue: Queue):
self.search_queue = search_queue
self.search_result_queue = search_result_queue
threading.Thread.__init__(self)
def run(self) -> None:

View File

@@ -110,13 +110,13 @@ class EncyclopaediaMetallum(Page):
SOURCE_TYPE = SourcePages.ENCYCLOPAEDIA_METALLUM
LOGGER = ENCYCLOPAEDIA_METALLUM_LOGGER
def __init__(self):
def __init__(self, **kwargs):
self.connection: Connection = Connection(
host="https://www.metal-archives.com/",
logger=ENCYCLOPAEDIA_METALLUM_LOGGER
)
super().__init__()
super().__init__(**kwargs)
def song_search(self, song: Song) -> List[Song]:
endpoint = "https://www.metal-archives.com/search/ajax-advanced/searching/songs/?songTitle={song}&bandName={" \

View File

@@ -115,13 +115,13 @@ class Musify(Page):
HOST = "https://musify.club"
def __init__(self):
def __init__(self, *args, **kwargs):
self.connection: Connection = Connection(
host="https://musify.club/",
logger=self.LOGGER
)
super().__init__()
super().__init__(*args, **kwargs)
def get_source_type(self, source: Source) -> Optional[Type[DatabaseObject]]:
if source.url is None:

View File

@@ -20,13 +20,13 @@ class Preset(Page):
SOURCE_TYPE = SourcePages.PRESET
LOGGER = logging.getLogger("preset")
def __init__(self):
def __init__(self, *args, **kwargs):
self.connection: Connection = Connection(
host="https://www.preset.cum/",
logger=self.LOGGER
)
super().__init__()
super().__init__(*args, **kwargs)
def get_source_type(self, source: Source) -> Optional[Type[DatabaseObject]]:
return super().get_source_type(source)