allow for excluding cache on lyrics search (temp?) + addl genius fixes
This commit is contained in:
parent
fed5307386
commit
c4ae59ca9f
@ -47,7 +47,7 @@ class Aggregate:
|
|||||||
search_result: Optional[LyricsResult] = None
|
search_result: Optional[LyricsResult] = None
|
||||||
for source in sources:
|
for source in sources:
|
||||||
if source.label.lower() in self.exclude_methods:
|
if source.label.lower() in self.exclude_methods:
|
||||||
if source.label.lower() == "cache" or not plain:
|
if not plain:
|
||||||
logging.info("Exclude conditions rejected - source requested to exclude: %s, plain: %s",
|
logging.info("Exclude conditions rejected - source requested to exclude: %s, plain: %s",
|
||||||
source.label, plain)
|
source.label, plain)
|
||||||
else:
|
else:
|
||||||
|
@ -3,6 +3,7 @@ sys.path.insert(1,'..')
|
|||||||
import traceback
|
import traceback
|
||||||
import logging
|
import logging
|
||||||
import time
|
import time
|
||||||
|
import re
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
from aiohttp import ClientTimeout, ClientSession
|
from aiohttp import ClientTimeout, ClientSession
|
||||||
from bs4 import BeautifulSoup, ResultSet # type: ignore
|
from bs4 import BeautifulSoup, ResultSet # type: ignore
|
||||||
@ -101,16 +102,23 @@ class Genius:
|
|||||||
|
|
||||||
|
|
||||||
html = BeautifulSoup(htm.unescape(scrape_text).replace('<br/>', '\n'), "html.parser")
|
html = BeautifulSoup(htm.unescape(scrape_text).replace('<br/>', '\n'), "html.parser")
|
||||||
header_tags: Optional[ResultSet] = html.find_all(['h1', 'h2', 'h3', 'h4', 'h5', 'span'])
|
|
||||||
if header_tags:
|
header_tags_genius: Optional[ResultSet] = html.find_all(class_=re.compile('.*Header.*'))
|
||||||
for tag in header_tags:
|
if header_tags_genius:
|
||||||
|
for tag in header_tags_genius:
|
||||||
tag.extract()
|
tag.extract()
|
||||||
|
|
||||||
divs: Optional[ResultSet] = html.find_all("div", {"data-lyrics-container": "true"})
|
divs: Optional[ResultSet] = html.find_all("div", {"data-lyrics-container": "true"})
|
||||||
|
|
||||||
if not divs:
|
if not divs:
|
||||||
return
|
return
|
||||||
|
|
||||||
for div in divs:
|
for div in divs:
|
||||||
|
header_tags: Optional[ResultSet] = div.find_all(['h1', 'h2', 'h3', 'h4', 'h5'])
|
||||||
|
if header_tags:
|
||||||
|
for tag in header_tags:
|
||||||
|
tag.extract()
|
||||||
|
|
||||||
returned_lyrics += div.get_text()
|
returned_lyrics += div.get_text()
|
||||||
|
|
||||||
returned_lyrics: str = self.datautils.scrub_lyrics(returned_lyrics)
|
returned_lyrics: str = self.datautils.scrub_lyrics(returned_lyrics)
|
||||||
|
@ -186,15 +186,15 @@ class RadioUtil:
|
|||||||
LIMITED TO ONE/SMALL SUBSET OF GENRES
|
LIMITED TO ONE/SMALL SUBSET OF GENRES
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# db_query = 'SELECT distinct(artist || " - " || song) AS artistdashsong, id, artist, song, album, genre, file_path, duration FROM tracks\
|
db_query = 'SELECT distinct(artist || " - " || song) AS artistdashsong, id, artist, song, album, genre, file_path, duration FROM tracks\
|
||||||
# WHERE artist LIKE "%tethered%" OR artist LIKE "%more of mysel%" ORDER BY artist DESC, album ASC, song ASC'
|
WHERE genre LIKE "%edm%" OR artist LIKE "%sullivan king%" OR artist LIKE "%kai wachi%" OR artist LIKE "%kayzo%" ORDER BY RANDOM()' #ORDER BY artist DESC, album ASC, song ASC'
|
||||||
|
|
||||||
"""
|
"""
|
||||||
LIMITED TO ONE/SOME ARTISTS...
|
LIMITED TO ONE/SOME ARTISTS...
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# db_query = 'SELECT distinct(artist || " - " || song) AS artistdashsong, id, artist, song, album, genre, file_path, duration FROM tracks\
|
# db_query = 'SELECT distinct(artist || " - " || song) AS artistdashsong, id, artist, song, album, genre, file_path, duration FROM tracks\
|
||||||
# WHERE (artist LIKE "%sullivan king%" OR artist LIKE "%kayzo%" OR artist like "%kai wachi%" OR genre LIKE "%edm%" OR genre LIKE "%electronicore%") AND (NOT song LIKE "%%stripped%%" AND NOT song LIKE "%(2022)%" AND NOT song LIKE "%(live%%" AND NOT song LIKE "%%acoustic%%" AND NOT song LIKE "%%instrumental%%" AND NOT song LIKE "%%remix%%" AND NOT song LIKE "%%reimagined%%" AND NOT song LIKE "%%alternative%%" AND NOT song LIKE "%%unzipped%%") GROUP BY artistdashsong ORDER BY RANDOM()'# ORDER BY album ASC, id ASC'
|
# WHERE (artist LIKE "%a scent like wolves%" OR artist LIKE "%bad wolves%" or artist LIKE "%oceans%" OR artist LIKE "%oh,%" OR artist LIKE "%august%" OR artist LIKE "%periphery%") AND (NOT song LIKE "%%stripped%%" AND NOT song LIKE "%(2022)%" AND NOT song LIKE "%(live%%" AND NOT song LIKE "%%acoustic%%" AND NOT song LIKE "%%instrumental%%" AND NOT song LIKE "%%remix%%" AND NOT song LIKE "%%reimagined%%" AND NOT song LIKE "%%alternative%%" AND NOT song LIKE "%%unzipped%%") GROUP BY artistdashsong ORDER BY RANDOM()'# ORDER BY album ASC, id ASC'
|
||||||
|
|
||||||
async with sqlite3.connect(self.active_playlist_path,
|
async with sqlite3.connect(self.active_playlist_path,
|
||||||
timeout=2) as db_conn:
|
timeout=2) as db_conn:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user