mirror of
https://github.com/migatu/conjurer.git
synced 2026-07-15 05:48:35 +00:00
Compare commits
18 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 85be1ce9fc | |||
| a68745713b | |||
| bbe1b89007 | |||
| 27fefdccb5 | |||
| 64849f728f | |||
| 9b09c2c13f | |||
| f2fb2232ee | |||
| 7e4dfbf8cd | |||
| 81a387eb4f | |||
| 408f6e5c4e | |||
| a266e5d240 | |||
| 917b57c586 | |||
| 0e15218abd | |||
| f56773b2e1 | |||
| 944dfe2c18 | |||
| 2fd362a1d5 | |||
| 47945ab3dd | |||
| c0b362df6d |
@@ -201,3 +201,4 @@ cr_results.json
|
|||||||
not_in_db.json
|
not_in_db.json
|
||||||
rr_results.json
|
rr_results.json
|
||||||
s_results.json
|
s_results.json
|
||||||
|
*.bak
|
||||||
@@ -136,10 +136,15 @@ MUZYKA_MOJEGO_LUDU_SLOWA_KLUCZOWE = 15
|
|||||||
MUZYKA_MOJEGO_LUDU_PLAJLISTA = 30
|
MUZYKA_MOJEGO_LUDU_PLAJLISTA = 30
|
||||||
|
|
||||||
FILE_SERVICE_ADDRESS = "http://192.168.1.15:5000"
|
FILE_SERVICE_ADDRESS = "http://192.168.1.15:5000"
|
||||||
|
RADIO_HARBOR_ADDRESS = "http://192.168.1.15:54321"
|
||||||
|
SKIP_TRACK = "/skip"
|
||||||
|
|
||||||
GET_MP3 = "/mp3"
|
GET_MP3 = "/mp3"
|
||||||
SEND_MP3 = "/update_mp3"
|
SEND_MP3 = "/update_mp3"
|
||||||
GET_PLAYLIST = "/get_music"
|
GET_PLAYLIST = "/get_music"
|
||||||
ADD_TO_PRIO_PLAYLIST = "/add_to_priority"
|
ADD_TO_PRIO_PLAYLIST = "/add_to_priority"
|
||||||
|
CREATE_PRIO_PLAYLIST = "/create_priority_playlist"
|
||||||
|
|
||||||
REQUEST_MUSIC = "/request_radio_file"
|
REQUEST_MUSIC = "/request_radio_file"
|
||||||
CLEAR_PRIO = "/clear_pr_pls"
|
CLEAR_PRIO = "/clear_pr_pls"
|
||||||
LIBRARIAN_SERVICE_ADDRESS = "http://192.168.1.192:5001"
|
LIBRARIAN_SERVICE_ADDRESS = "http://192.168.1.192:5001"
|
||||||
@@ -1355,10 +1360,19 @@ async def skip_track(ctx):
|
|||||||
async with ctx.typing():
|
async with ctx.typing():
|
||||||
allowed = False
|
allowed = False
|
||||||
for role in ctx.author.roles:
|
for role in ctx.author.roles:
|
||||||
if role.name == "Thane":
|
if role.name in ("Thane","Jarl"):
|
||||||
allowed = True
|
allowed = True
|
||||||
if not allowed:
|
if not allowed:
|
||||||
await ctx.send("Łapy precz od radia")
|
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(
|
@client.hybrid_command(
|
||||||
@@ -1370,13 +1384,13 @@ async def zrestartuj_radio(ctx):
|
|||||||
async with ctx.typing():
|
async with ctx.typing():
|
||||||
allowed = False
|
allowed = False
|
||||||
for role in ctx.author.roles:
|
for role in ctx.author.roles:
|
||||||
if role.name == "Thane":
|
if role.name in ("Thane","Jarl"):
|
||||||
allowed = True
|
allowed = True
|
||||||
if not allowed:
|
if not allowed:
|
||||||
await ctx.send("Łapy precz od radia")
|
await ctx.send("Łapy precz od radia")
|
||||||
else:
|
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(
|
@client.hybrid_command(
|
||||||
name="dej_co_ze_spotifaja",
|
name="dej_co_ze_spotifaja",
|
||||||
@@ -1827,7 +1841,9 @@ async def dodaj_do_ulubionych(ctx):
|
|||||||
json=jrequest,
|
json=jrequest,
|
||||||
timeout=360,
|
timeout=360,
|
||||||
)
|
)
|
||||||
_ = await coroutine
|
result = await coroutine
|
||||||
|
logger.info("Done %s", result)
|
||||||
|
await ctx.send("Zrobione szefie!")
|
||||||
@client.hybrid_command(
|
@client.hybrid_command(
|
||||||
name="ja_chciol",
|
name="ja_chciol",
|
||||||
description="Dodaje do listy ulubionych w radiu",
|
description="Dodaje do listy ulubionych w radiu",
|
||||||
@@ -1857,7 +1873,46 @@ async def request_radio(ctx):
|
|||||||
json=jrequest,
|
json=jrequest,
|
||||||
timeout=360,
|
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(
|
@client.hybrid_command(
|
||||||
name="wyczysc_ulubione",
|
name="wyczysc_ulubione",
|
||||||
description="Czysci liste ulubionych w radiu",
|
description="Czysci liste ulubionych w radiu",
|
||||||
@@ -1879,7 +1934,9 @@ async def wyczysc_ulubione(ctx):
|
|||||||
f"{FILE_SERVICE_ADDRESS}{CLEAR_PRIO}",
|
f"{FILE_SERVICE_ADDRESS}{CLEAR_PRIO}",
|
||||||
timeout=360,
|
timeout=360,
|
||||||
)
|
)
|
||||||
_ = await coroutine
|
result = await coroutine
|
||||||
|
logger.info("Done %s", result)
|
||||||
|
await ctx.send("Zrobione szefie!")
|
||||||
|
|
||||||
|
|
||||||
@client.hybrid_command(
|
@client.hybrid_command(
|
||||||
@@ -2406,7 +2463,7 @@ async def krecimy_pornola(ctx):
|
|||||||
sciezka, files = await get_file(ctx, "Pornol", item_yt)
|
sciezka, files = await get_file(ctx, "Pornol", item_yt)
|
||||||
if files:
|
if files:
|
||||||
logger.info("Pornol udany")
|
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:
|
else:
|
||||||
ctx.reply("Jak ładnie szefa poprosisz.")
|
ctx.reply("Jak ładnie szefa poprosisz.")
|
||||||
|
|
||||||
@@ -2431,10 +2488,3 @@ if __name__ == "__main__":
|
|||||||
WRK_CNT+=1
|
WRK_CNT+=1
|
||||||
logger.info("Starting discord bot: Joining thread %s", WRK_CNT)
|
logger.info("Starting discord bot: Joining thread %s", WRK_CNT)
|
||||||
worker.join()
|
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
|
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ MAIN_BOT_ADDRESS = "http://192.168.1.191:5000"
|
|||||||
SEND_RESULTS = "/conjurer"
|
SEND_RESULTS = "/conjurer"
|
||||||
BDSM_UUID_TEST = "96b7f85a-1142-4908-8986-62a2ea25a147"
|
BDSM_UUID_TEST = "96b7f85a-1142-4908-8986-62a2ea25a147"
|
||||||
|
|
||||||
MAX_CR_RESULTS = 1000
|
MAX_CR_RESULTS = 500
|
||||||
#TEST PURPOSES ONLY!
|
#TEST PURPOSES ONLY!
|
||||||
#MAX_CR_RESULTS = 5
|
#MAX_CR_RESULTS = 5
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -104,9 +104,8 @@ def check_if_exists_brute_force(logger):
|
|||||||
pass
|
pass
|
||||||
if blocked:
|
if blocked:
|
||||||
logger.info(item)
|
logger.info(item)
|
||||||
logger.info(text)
|
|
||||||
logger.error("Got blocked. Fuck.")
|
logger.error("Got blocked. Fuck.")
|
||||||
time.sleep(60 * 60 * 72)
|
time.sleep(60 * 60)
|
||||||
# trunk-ignore(bandit/B311)
|
# trunk-ignore(bandit/B311)
|
||||||
rand = random.randint(1, 60)
|
rand = random.randint(1, 60)
|
||||||
logger.info(f"Sleeping for {2*rand} minutes")
|
logger.info(f"Sleeping for {2*rand} minutes")
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ from queue import Empty, Queue
|
|||||||
from threading import Thread
|
from threading import Thread
|
||||||
import time
|
import time
|
||||||
q = Queue()
|
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
|
# DATA FOR TEST ONLY
|
||||||
# MAXTHREADS = 5
|
# MAXTHREADS = 5
|
||||||
|
|||||||
@@ -206,6 +206,7 @@ def wyszukaj(word_list, how_many, _logger=None, return_to_bot=True):
|
|||||||
fun_logger.info("Wiele plików do zagrania")
|
fun_logger.info("Wiele plików do zagrania")
|
||||||
search_weight.sort(key=lambda x: x[0], reverse=True)
|
search_weight.sort(key=lambda x: x[0], reverse=True)
|
||||||
return_list.extend(search_weight[: int(how_many)])
|
return_list.extend(search_weight[: int(how_many)])
|
||||||
|
fun_logger.info("Done: %s", return_list)
|
||||||
return return_list
|
return return_list
|
||||||
|
|
||||||
|
|
||||||
@@ -369,6 +370,37 @@ def add_request():
|
|||||||
)
|
)
|
||||||
return return_data
|
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"])
|
@app.route("/add_to_priority", methods=["POST"])
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -34,10 +34,9 @@ requests_queue = request.queue()
|
|||||||
|
|
||||||
# Function to process the request queue and add new requests
|
# Function to process the request queue and add new requests
|
||||||
def queue_processing()
|
def queue_processing()
|
||||||
f1=file.read("/home/pi/Conjurer/request.playlist")
|
text=file.lines("/home/pi/Conjurer/request.playlist")
|
||||||
text = f1()
|
if text != [] then
|
||||||
if text != "" then
|
list.iter(fun(item) -> requests_queue.push.uri(item), text)
|
||||||
requests_queue.push.uri(text)
|
|
||||||
file.remove("/home/pi/Conjurer/request.playlist")
|
file.remove("/home/pi/Conjurer/request.playlist")
|
||||||
f = file.open("/home/pi/Conjurer/request.playlist", create=true)
|
f = file.open("/home/pi/Conjurer/request.playlist", create=true)
|
||||||
f.close()
|
f.close()
|
||||||
@@ -45,7 +44,7 @@ def queue_processing()
|
|||||||
end
|
end
|
||||||
|
|
||||||
# Randomly select a playlist with weights
|
# 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
|
# Load jingles playlist
|
||||||
jingles = (playlist(reload_mode="watch", "/home/pi/Conjurer/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 = buffer(input.pulseaudio()) # Microphone
|
||||||
mic = gate(threshold=-30., range=-80., mic)
|
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])
|
s = add([s, mic])
|
||||||
#w = interactive.float("wetness", min=0., max=1., 1.)
|
#w = interactive.float("wetness", min=0., max=1., 1.)
|
||||||
@@ -82,7 +81,7 @@ s = add([s, mic])
|
|||||||
|
|
||||||
|
|
||||||
# Skip blank sections in the stream
|
# Skip blank sections in the stream
|
||||||
s = blank.skip(max_blank=2., s)
|
s = blank.skip(max_blank=10., s)
|
||||||
|
|
||||||
# Configure logging settings
|
# Configure logging settings
|
||||||
log_to_stdout = true
|
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
|
# Set up an interactive control for skipping tracks
|
||||||
p = interactive.bool("Skip track", false)
|
p = interactive.bool("Skip track", false)
|
||||||
|
|
||||||
def http_skip(_):
|
def http_skip(~protocol, ~data, ~headers, uri)=
|
||||||
radio.skip()
|
radio.skip()
|
||||||
http.response(data="Skipped")
|
http.response(code=200,data="Skipped")
|
||||||
end
|
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
|
# Function to process the request queue and skip the current track if requested
|
||||||
|
|||||||
Reference in New Issue
Block a user