Fixed playlist gen

This commit is contained in:
2023-06-07 00:44:00 +02:00
parent 42bee72e88
commit ee4f39de42
+23 -31
View File
@@ -52,7 +52,7 @@ elif platform == "win32":
music_folder = "G:\\Muzyka\\"
settings_file = "settings.json"
netrc_file = "C:\\Users\\mtusz\\.netrc"
logstore = "C:\\users\\mtusz\\OneDrive\\Pulpit\\Conjurer\\logs\\"
logstore = "C:\\Users\\mtusz\\OneDrive\\Pulpit\\Conjurer\\logs\\"
# *=========================================== Keys
netrc = netrc.netrc(netrc_file)
@@ -141,9 +141,12 @@ async def on_message(message):
if ("Conjurer Śpij Słodko Aniołku" in message.content) and vykidailo:
exit()
#kanal bez bota
if message.channel.id == 1095985579147141202:
return
#wentylacja
if message.channel.id == 1083804024173764739:
return
if isinstance(message.channel, discord.DMChannel):
channel = client.get_channel(1064888712565100614)
@@ -299,7 +302,7 @@ async def play(ctx, zamawial=None, arg=None):
voiceClient.play(
discord.PCMVolumeTransformer(
discord.FFmpegPCMAudio(source=file_to_play), volume=0.15
discord.FFmpegPCMAudio(source=file_to_play), volume=0.3
)
) # NIE DOTYKAC POKRĘTŁA GŁOŚNOŚCI!!!!
if query:
@@ -531,8 +534,13 @@ async def wyszukaj(ctx, how_many=0):
search_weight.append((0, ""))
time_start = datetime.now()
for word in word_list[1:]:
if int(how_many) > 0:
skip_start = 2
else:
skip_start = 1
for word in word_list[skip_start:]:
token_weight = len(word)
logger.info("Słowo kluczowe: {}".format(word))
itr = 0
for file in music_file_list:
if platform == "win32":
@@ -568,7 +576,6 @@ async def wyszukaj(ctx, how_many=0):
all_words.extend(tmp)
pingu = 1
pattern_len = len(all_words)
plapka = False
if platform == "win32":
skip = 2
else:
@@ -583,10 +590,8 @@ async def wyszukaj(ctx, how_many=0):
+ (token_weight + (pingu**1.5) / pattern_len) / matched_times
)
search_weight[itr] = temp_weight, music_file_list[itr]
matched_times += 1
itr += 1
await asyncio.sleep(1e-3)
logger.info(
"Stworzylem tablice wag zajęło mi to {}".format(datetime.now() - time_start)
@@ -600,30 +605,17 @@ async def wyszukaj(ctx, how_many=0):
return_list = []
if int(how_many) <= 0:
logger.info("Jeden plik do zagrania")
while not_found:
if search_weight[itr][0] == item_to_search:
return_list.append(search_weight[itr][1])
return_list.append(search_weight[itr])
return return_list
itr += 1
else:
logger.info("Wiele plików do zagrania")
for i in range(int(how_many)):
item_to_search = await max_weight(search_weight)
while not_found:
if search_weight[itr][0] == item_to_search:
return_list.append(search_weight[itr][1])
search_weight.remove(search_weight[itr])
itr = 0
logger.info("Zajęło mi to {}".format(datetime.now() - time_start))
item_to_search = await max_weight(search_weight)
else:
itr += 1
if await max_weight(search_weight) < 5:
return return_list
if len(return_list) >= int(how_many):
logger.info("Zajęło mi to {}".format(datetime.now() - time_start))
return return_list
search_weight.sort(key = lambda x: x[0],reverse=True)
return_list.extend(search_weight[:int(how_many)])
return return_list
async def max_weight(list):
@@ -881,11 +873,11 @@ async def zagraj_mi_kawalek(ctx, arg=None):
if file:
for plik in file:
global MUZYKA
MUZYKA["queue"].insert(0, plik)
MUZYKA["queue"].insert(0, plik[1])
MUZYKA["requestor"].insert(0, ctx.author)
metadata = eyed3.load(plik)
metadata = eyed3.load(plik[1])
reply = "Dodałem do playlisty {} z prywatnej kolekcji Hammera.".format(
plik
plik[1]
)
if metadata.tag.title:
reply = "Dodałem do playlisty kawalek {}".format(metadata.tag.title)
@@ -917,11 +909,11 @@ async def zrob_mi_plejliste(ctx, *arg):
if file:
for plik in file:
global MUZYKA
MUZYKA["queue"].insert(0, plik)
MUZYKA["queue"].insert(0, plik[1])
MUZYKA["requestor"].insert(0, ctx.author)
metadata = eyed3.load(plik)
metadata = eyed3.load(plik[1])
reply = "Dodałem do playlisty {} z prywatnej kolekcji Hammera.".format(
plik
plik[1]
)
if metadata.tag.title:
reply = "Dodałem do playlisty kawalek {}".format(metadata.tag.title)