Compare commits

...

18 Commits

Author SHA1 Message Date
gitea 85be1ce9fc Small fix 2025-01-05 22:09:43 +01:00
gitea a68745713b Change in weights 2024-07-20 13:27:40 +02:00
gitea bbe1b89007 Fix logging0 2024-07-20 11:13:36 +02:00
gitea 27fefdccb5 Added more logging 2024-07-20 09:55:32 +02:00
gitea 64849f728f Fixed :) 2024-07-20 09:50:24 +02:00
gitea 9b09c2c13f Fix 2024-07-20 09:41:42 +02:00
gitea f2fb2232ee Audition 2024-07-20 09:09:14 +02:00
gitea 7e4dfbf8cd NEw util 2024-07-20 09:00:51 +02:00
gitea 81a387eb4f Best tracks 2024-07-07 19:46:45 +02:00
gitea 408f6e5c4e fix 2024-06-19 19:47:15 +02:00
gitea a266e5d240 Skip track 2024-06-19 19:45:36 +02:00
gitea 917b57c586 Fix 2024-06-19 18:55:48 +02:00
gitea 0e15218abd Test 2024-06-19 18:53:37 +02:00
gitea f56773b2e1 test2 2024-06-19 18:46:40 +02:00
gitea 944dfe2c18 test 2024-06-19 18:39:51 +02:00
gitea 2fd362a1d5 another approach 2024-06-19 18:31:10 +02:00
gitea 47945ab3dd path fix 2024-06-19 18:24:02 +02:00
gitea c0b362df6d fix of permissions 2024-06-19 18:22:39 +02:00
9 changed files with 132 additions and 28 deletions
+1
View File
@@ -201,3 +201,4 @@ cr_results.json
not_in_db.json
rr_results.json
s_results.json
*.bak
+65 -15
View File
@@ -136,10 +136,15 @@ MUZYKA_MOJEGO_LUDU_SLOWA_KLUCZOWE = 15
MUZYKA_MOJEGO_LUDU_PLAJLISTA = 30
FILE_SERVICE_ADDRESS = "http://192.168.1.15:5000"
RADIO_HARBOR_ADDRESS = "http://192.168.1.15:54321"
SKIP_TRACK = "/skip"
GET_MP3 = "/mp3"
SEND_MP3 = "/update_mp3"
GET_PLAYLIST = "/get_music"
ADD_TO_PRIO_PLAYLIST = "/add_to_priority"
CREATE_PRIO_PLAYLIST = "/create_priority_playlist"
REQUEST_MUSIC = "/request_radio_file"
CLEAR_PRIO = "/clear_pr_pls"
LIBRARIAN_SERVICE_ADDRESS = "http://192.168.1.192:5001"
@@ -1355,10 +1360,19 @@ async def skip_track(ctx):
async with ctx.typing():
allowed = False
for role in ctx.author.roles:
if role.name == "Thane":
if role.name in ("Thane","Jarl"):
allowed = True
if not allowed:
await ctx.send("Łapy precz od radia")
else:
coroutine = asyncio.to_thread(
requests.get,
f"{RADIO_HARBOR_ADDRESS}{SKIP_TRACK}",
timeout=360,
)
result = await coroutine
logger.info("Done %s", result)
await ctx.send("Zrobione szefie!")
@client.hybrid_command(
@@ -1370,13 +1384,13 @@ async def zrestartuj_radio(ctx):
async with ctx.typing():
allowed = False
for role in ctx.author.roles:
if role.name == "Thane":
if role.name in ("Thane","Jarl"):
allowed = True
if not allowed:
await ctx.send("Łapy precz od radia")
else:
subprocess.call(['sh', './restart_radio.sh'])
retcode = subprocess.run("/home/pi/Conjurer/restart_radio.sh", shell=False, check = False, capture_output = True)
logger.info("Wynik: %s",retcode)
@client.hybrid_command(
name="dej_co_ze_spotifaja",
@@ -1827,7 +1841,9 @@ async def dodaj_do_ulubionych(ctx):
json=jrequest,
timeout=360,
)
_ = await coroutine
result = await coroutine
logger.info("Done %s", result)
await ctx.send("Zrobione szefie!")
@client.hybrid_command(
name="ja_chciol",
description="Dodaje do listy ulubionych w radiu",
@@ -1857,7 +1873,46 @@ async def request_radio(ctx):
json=jrequest,
timeout=360,
)
_ = await coroutine
result = await coroutine
logger.info("Done %s", result)
await ctx.send("Zrobione szefie!")
@client.hybrid_command(
name="stworz_audycje",
description="Dodaje do listy ulubionych w radiu",
guild=discord.Object(id=664789470779932693),
)
async def stworz_audycje(ctx):
"""
Generate a playlist in queue. First word in this command shall be int defining length of the playlist.
Rest of the line are search terms.
:param ctx: ctx stands for "context" and is a parameter commonly used in Discord.py commands. It
represents the context in which the command was invoked, including information such as the message,
the channel, the server, and the user who invoked the command. This parameter is required in all
Discord.py commands
"""
async with ctx.typing():
logger.info("Zaczynam szukać timestamp %s", datetime.now())
dlugosc_playlisty = ctx.message.content.split()[1]
word_list = ctx.message.content.split()
jrequest = {
"lista_slow": word_list,
"dlugosc_plejlisty": dlugosc_playlisty,
"UUID": str(uuid.uuid4()),
}
coroutine = asyncio.to_thread(
requests.post,
f"{FILE_SERVICE_ADDRESS}{CREATE_PRIO_PLAYLIST}",
json=jrequest,
timeout=360,
)
result = await coroutine
logger.info("Done %s", result)
await ctx.send("Zrobione szefie!")
@client.hybrid_command(
name="wyczysc_ulubione",
description="Czysci liste ulubionych w radiu",
@@ -1879,7 +1934,9 @@ async def wyczysc_ulubione(ctx):
f"{FILE_SERVICE_ADDRESS}{CLEAR_PRIO}",
timeout=360,
)
_ = await coroutine
result = await coroutine
logger.info("Done %s", result)
await ctx.send("Zrobione szefie!")
@client.hybrid_command(
@@ -2406,7 +2463,7 @@ async def krecimy_pornola(ctx):
sciezka, files = await get_file(ctx, "Pornol", item_yt)
if files:
logger.info("Pornol udany")
ctx.reply(f"Jest w tajnym archiwum pod adresem{sciezka})")
ctx.send(f"Jest w tajnym archiwum pod adresem{sciezka})")
else:
ctx.reply("Jak ładnie szefa poprosisz.")
@@ -2431,10 +2488,3 @@ if __name__ == "__main__":
WRK_CNT+=1
logger.info("Starting discord bot: Joining thread %s", WRK_CNT)
worker.join()
# widok - generuje się 5 stron po 4 linki
# odśwież - zamienić na "dalej" - zaciąga kolejne 20 rezultatów
# po wyslaniu czekamy na odbior i dodajemy UUID oraz nick poszukiwacza do queue ktora jest sprawdzana
# flask sobie chodzi i jak dostaje posta z wynikami to wyciaga z queue UUID i odpowiada że znalazła
# po samym wyszukaniu dajemy info że "Zaczynam szukać ale pare godzin to potrwa."
# OPCJONALNIE: Dosyłamy znalezione wyniki na bieżąco - wtedy wkładamy do queue dla UUID wyniki
+1 -1
View File
@@ -39,7 +39,7 @@ MAIN_BOT_ADDRESS = "http://192.168.1.191:5000"
SEND_RESULTS = "/conjurer"
BDSM_UUID_TEST = "96b7f85a-1142-4908-8986-62a2ea25a147"
MAX_CR_RESULTS = 1000
MAX_CR_RESULTS = 500
#TEST PURPOSES ONLY!
#MAX_CR_RESULTS = 5
+8
View File
@@ -0,0 +1,8 @@
FILEPTH = r"C:\Database\chunks\4_chunk.txt"
with open(FILEPTH, "r", encoding="utf-8") as file:
tab = file.readlines()
print(len(tab))
#1842295
+1 -2
View File
@@ -104,9 +104,8 @@ def check_if_exists_brute_force(logger):
pass
if blocked:
logger.info(item)
logger.info(text)
logger.error("Got blocked. Fuck.")
time.sleep(60 * 60 * 72)
time.sleep(60 * 60)
# trunk-ignore(bandit/B311)
rand = random.randint(1, 60)
logger.info(f"Sleeping for {2*rand} minutes")
+1
View File
@@ -23,6 +23,7 @@ from queue import Empty, Queue
from threading import Thread
import time
q = Queue()
#TODO: Count number of lines in files and print to approximate on which part of the file search is
# DATA FOR TEST ONLY
# MAXTHREADS = 5
+32
View File
@@ -206,6 +206,7 @@ def wyszukaj(word_list, how_many, _logger=None, return_to_bot=True):
fun_logger.info("Wiele plików do zagrania")
search_weight.sort(key=lambda x: x[0], reverse=True)
return_list.extend(search_weight[: int(how_many)])
fun_logger.info("Done: %s", return_list)
return return_list
@@ -369,6 +370,37 @@ def add_request():
)
return return_data
@app.route("/create_priority_playlist", methods=["POST"])
def create_priority_playlist():
"""
The function `create_priority_playlist` receives a POST request with a JSON payload, logs the received
item, adds it to a music file list, and returns a success message along with the updated record.
:return: A tuple containing a JSON response and a status code.
The JSON response includes keys `isError`,
`message`, `statusCode`, and `data`, with values
indicating the success of the operation and the
data that was received and added to the `music_file_list`.
The status code returned is 200,indicating a successful response.
"""
record = json.loads(request.data)
app.logger.info(record)
app.logger.info(record["lista_slow"])
app.logger.info(record["UUID"])
app.logger.info(record["dlugosc_plejlisty"])
return_data = wyszukaj(
record["lista_slow"], record["dlugosc_plejlisty"], app.logger, False
)
with open(
"/home/pi/Conjurer/request.playlist", "a", encoding="utf-8"
) as s_file:
for item in return_data:
s_file.write(item[1] + "\n")
return_data = (
jsonify(isError=False, message="Success", statusCode=200, data={"status": "OK"}),
200,
)
return return_data
@app.route("/add_to_priority", methods=["POST"])
+14
View File
@@ -0,0 +1,14 @@
$dodaj_do_ulubionych 100 nightwish
$dodaj_do_ulubionych 100 amon amarth
$dodaj_do_ulubionych 100 tactical sekt
$dodaj_do_ulubionych 100 lacuna coil
$dodaj_do_ulubionych 100 sefa
$dodaj_do_ulubionych 100 frenchcore
$dodaj_do_ulubionych 100 peacock
$dodaj_do_ulubionych 100 vavamuffin
$dodaj_do_ulubionych 100 abradab
$dodaj_do_ulubionych 100 eluveitie
$dodaj_do_ulubionych 100 youtube
$dodaj_do_ulubionych 100 elyose
$dodaj_do_ulubionych 1 artisans du chaos
+9 -10
View File
@@ -34,10 +34,9 @@ requests_queue = request.queue()
# Function to process the request queue and add new requests
def queue_processing()
f1=file.read("/home/pi/Conjurer/request.playlist")
text = f1()
if text != "" then
requests_queue.push.uri(text)
text=file.lines("/home/pi/Conjurer/request.playlist")
if text != [] then
list.iter(fun(item) -> requests_queue.push.uri(item), text)
file.remove("/home/pi/Conjurer/request.playlist")
f = file.open("/home/pi/Conjurer/request.playlist", create=true)
f.close()
@@ -45,7 +44,7 @@ def queue_processing()
end
# Randomly select a playlist with weights
s4 = random(id="randomizer", weights=[1, 3, 5], [s1, s2, s3])
s4 = random(id="randomizer", weights=[2, 3, 5], [s1, s2, s3])
# Load jingles playlist
jingles = (playlist(reload_mode="watch", "/home/pi/Conjurer/jingles.playlist"))
@@ -74,7 +73,7 @@ s = amplify(a, s)
mic = buffer(input.pulseaudio()) # Microphone
mic = gate(threshold=-30., range=-80., mic)
mic = blank.strip(max_blank=2., min_noise=.1, threshold=-20., mic)
mic = blank.strip(max_blank=10., min_noise=.1, threshold=-20., mic)
s = add([s, mic])
#w = interactive.float("wetness", min=0., max=1., 1.)
@@ -82,7 +81,7 @@ s = add([s, mic])
# Skip blank sections in the stream
s = blank.skip(max_blank=2., s)
s = blank.skip(max_blank=10., s)
# Configure logging settings
log_to_stdout = true
@@ -102,11 +101,11 @@ radio = fallback(id="switcher2", track_sensitive=false, [s, emergency])
# Set up an interactive control for skipping tracks
p = interactive.bool("Skip track", false)
def http_skip(_):
def http_skip(~protocol, ~data, ~headers, uri)=
radio.skip()
http.response(data="Skipped")
http.response(code=200,data="Skipped")
end
harbor.http.register.simple(port=54321, "/skip", http_skip)
harbor.http.register(port=54321,method="GET","/skip", http_skip)
# Function to process the request queue and skip the current track if requested