mirror of
https://github.com/migatu/conjurer.git
synced 2026-07-16 06:42:10 +00:00
Fixed playlist gen
This commit is contained in:
@@ -52,7 +52,7 @@ elif platform == "win32":
|
|||||||
music_folder = "G:\\Muzyka\\"
|
music_folder = "G:\\Muzyka\\"
|
||||||
settings_file = "settings.json"
|
settings_file = "settings.json"
|
||||||
netrc_file = "C:\\Users\\mtusz\\.netrc"
|
netrc_file = "C:\\Users\\mtusz\\.netrc"
|
||||||
logstore = "C:\\users\\mtusz\\OneDrive\\Pulpit\\Conjurer\\logs\\"
|
logstore = "C:\\Users\\mtusz\\OneDrive\\Pulpit\\Conjurer\\logs\\"
|
||||||
|
|
||||||
# *=========================================== Keys
|
# *=========================================== Keys
|
||||||
netrc = netrc.netrc(netrc_file)
|
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:
|
if ("Conjurer Śpij Słodko Aniołku" in message.content) and vykidailo:
|
||||||
exit()
|
exit()
|
||||||
|
#kanal bez bota
|
||||||
if message.channel.id == 1095985579147141202:
|
if message.channel.id == 1095985579147141202:
|
||||||
return
|
return
|
||||||
|
#wentylacja
|
||||||
|
if message.channel.id == 1083804024173764739:
|
||||||
|
return
|
||||||
|
|
||||||
if isinstance(message.channel, discord.DMChannel):
|
if isinstance(message.channel, discord.DMChannel):
|
||||||
channel = client.get_channel(1064888712565100614)
|
channel = client.get_channel(1064888712565100614)
|
||||||
@@ -299,7 +302,7 @@ async def play(ctx, zamawial=None, arg=None):
|
|||||||
|
|
||||||
voiceClient.play(
|
voiceClient.play(
|
||||||
discord.PCMVolumeTransformer(
|
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!!!!
|
) # NIE DOTYKAC POKRĘTŁA GŁOŚNOŚCI!!!!
|
||||||
if query:
|
if query:
|
||||||
@@ -531,8 +534,13 @@ async def wyszukaj(ctx, how_many=0):
|
|||||||
search_weight.append((0, ""))
|
search_weight.append((0, ""))
|
||||||
|
|
||||||
time_start = datetime.now()
|
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)
|
token_weight = len(word)
|
||||||
|
logger.info("Słowo kluczowe: {}".format(word))
|
||||||
itr = 0
|
itr = 0
|
||||||
for file in music_file_list:
|
for file in music_file_list:
|
||||||
if platform == "win32":
|
if platform == "win32":
|
||||||
@@ -568,7 +576,6 @@ async def wyszukaj(ctx, how_many=0):
|
|||||||
all_words.extend(tmp)
|
all_words.extend(tmp)
|
||||||
pingu = 1
|
pingu = 1
|
||||||
pattern_len = len(all_words)
|
pattern_len = len(all_words)
|
||||||
plapka = False
|
|
||||||
if platform == "win32":
|
if platform == "win32":
|
||||||
skip = 2
|
skip = 2
|
||||||
else:
|
else:
|
||||||
@@ -583,10 +590,8 @@ async def wyszukaj(ctx, how_many=0):
|
|||||||
+ (token_weight + (pingu**1.5) / pattern_len) / matched_times
|
+ (token_weight + (pingu**1.5) / pattern_len) / matched_times
|
||||||
)
|
)
|
||||||
search_weight[itr] = temp_weight, music_file_list[itr]
|
search_weight[itr] = temp_weight, music_file_list[itr]
|
||||||
|
|
||||||
matched_times += 1
|
matched_times += 1
|
||||||
itr += 1
|
itr += 1
|
||||||
await asyncio.sleep(1e-3)
|
|
||||||
|
|
||||||
logger.info(
|
logger.info(
|
||||||
"Stworzylem tablice wag zajęło mi to {}".format(datetime.now() - time_start)
|
"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 = []
|
return_list = []
|
||||||
if int(how_many) <= 0:
|
if int(how_many) <= 0:
|
||||||
logger.info("Jeden plik do zagrania")
|
logger.info("Jeden plik do zagrania")
|
||||||
|
|
||||||
while not_found:
|
while not_found:
|
||||||
if search_weight[itr][0] == item_to_search:
|
if search_weight[itr][0] == item_to_search:
|
||||||
return_list.append(search_weight[itr][1])
|
return_list.append(search_weight[itr])
|
||||||
return return_list
|
return return_list
|
||||||
itr += 1
|
itr += 1
|
||||||
else:
|
else:
|
||||||
logger.info("Wiele plików do zagrania")
|
logger.info("Wiele plików do zagrania")
|
||||||
for i in range(int(how_many)):
|
search_weight.sort(key = lambda x: x[0],reverse=True)
|
||||||
item_to_search = await max_weight(search_weight)
|
return_list.extend(search_weight[:int(how_many)])
|
||||||
while not_found:
|
return return_list
|
||||||
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
|
|
||||||
|
|
||||||
|
|
||||||
async def max_weight(list):
|
async def max_weight(list):
|
||||||
@@ -881,11 +873,11 @@ async def zagraj_mi_kawalek(ctx, arg=None):
|
|||||||
if file:
|
if file:
|
||||||
for plik in file:
|
for plik in file:
|
||||||
global MUZYKA
|
global MUZYKA
|
||||||
MUZYKA["queue"].insert(0, plik)
|
MUZYKA["queue"].insert(0, plik[1])
|
||||||
MUZYKA["requestor"].insert(0, ctx.author)
|
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(
|
reply = "Dodałem do playlisty {} z prywatnej kolekcji Hammera.".format(
|
||||||
plik
|
plik[1]
|
||||||
)
|
)
|
||||||
if metadata.tag.title:
|
if metadata.tag.title:
|
||||||
reply = "Dodałem do playlisty kawalek {}".format(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:
|
if file:
|
||||||
for plik in file:
|
for plik in file:
|
||||||
global MUZYKA
|
global MUZYKA
|
||||||
MUZYKA["queue"].insert(0, plik)
|
MUZYKA["queue"].insert(0, plik[1])
|
||||||
MUZYKA["requestor"].insert(0, ctx.author)
|
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(
|
reply = "Dodałem do playlisty {} z prywatnej kolekcji Hammera.".format(
|
||||||
plik
|
plik[1]
|
||||||
)
|
)
|
||||||
if metadata.tag.title:
|
if metadata.tag.title:
|
||||||
reply = "Dodałem do playlisty kawalek {}".format(metadata.tag.title)
|
reply = "Dodałem do playlisty kawalek {}".format(metadata.tag.title)
|
||||||
|
|||||||
Reference in New Issue
Block a user