mirror of
https://github.com/migatu/conjurer.git
synced 2026-07-17 07:12:09 +00:00
Tag: 1.13
Intermediate commits (oldest → newest): - UPdate for music tracker - Buffx - Fix - Fix - tst fx - Fx frmt - fx frmt - Fx frmt - Now playing - bgfx - fx - Fix tracker - bgfx - fx - Fx
This commit is contained in:
@@ -47,6 +47,7 @@ from communication_subroutine import (
|
|||||||
OUT_COMM_Q,
|
OUT_COMM_Q,
|
||||||
QueryControl,
|
QueryControl,
|
||||||
comm_subroutine,
|
comm_subroutine,
|
||||||
|
PREPPED_TRACKS,
|
||||||
)
|
)
|
||||||
from spotify_dl import spotify
|
from spotify_dl import spotify
|
||||||
from spotify_dl import youtube as youtube_download
|
from spotify_dl import youtube as youtube_download
|
||||||
@@ -2520,10 +2521,29 @@ 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.send(f"Jest w tajnym archiwum pod adresem{sciezka})")
|
await ctx.send(f"Jest w tajnym archiwum pod adresem{sciezka})")
|
||||||
else:
|
else:
|
||||||
ctx.reply("Jak ładnie szefa poprosisz.")
|
await ctx.reply("Jak ładnie szefa poprosisz.")
|
||||||
|
|
||||||
|
@client.hybrid_command(
|
||||||
|
name="co_na_plejliscie_wariacie",
|
||||||
|
description="Wyswietl kawalki ktore sa na pocztku list radia",
|
||||||
|
guild=discord.Object(id=664789470779932693),
|
||||||
|
)
|
||||||
|
async def co_na_plejliscie_wariacie(ctx):
|
||||||
|
"""
|
||||||
|
Download a music number from youtube.
|
||||||
|
|
||||||
|
: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. It allows the command to interact
|
||||||
|
with the Discord API and
|
||||||
|
"""
|
||||||
|
await ctx.send("Dej mnie chwilkę")
|
||||||
|
async with ctx.typing():
|
||||||
|
logger.info("plejlista")
|
||||||
|
logger.info(PREPPED_TRACKS)
|
||||||
|
await ctx.send(f"Didżej Hammer i jego sztuczna inteligencja (||he he||) prezentują: \n- obecnie grany jest {(PREPPED_TRACKS['now_playing']).rstrip()} \n- na liście priorytetowej {(PREPPED_TRACKS['priority']).rstrip()} \n- na liście hitów obecnie czeka kawałek {(PREPPED_TRACKS['hit']).rstrip()} \n- na liście wszystkich kawałków {(PREPPED_TRACKS['all']).rstrip()} \n- najświeższym zamówieniem od słuchaczy jest {(PREPPED_TRACKS['requests']).rstrip()} \nZ kolei jingiel to: {(PREPPED_TRACKS['jingles']).rstrip()}")
|
||||||
|
|
||||||
# *================================== Run
|
# *================================== Run
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
@@ -2531,7 +2551,7 @@ if __name__ == "__main__":
|
|||||||
threads = []
|
threads = []
|
||||||
logger.info("Starting discord bot: Creating threads")
|
logger.info("Starting discord bot: Creating threads")
|
||||||
threads.append(threading.Thread(target=client.run, args=(TOKEN,)))
|
threads.append(threading.Thread(target=client.run, args=(TOKEN,)))
|
||||||
threads.append(threading.Thread(target=comm_subroutine, args=(logger,)))
|
threads.append(threading.Thread(target=comm_subroutine))
|
||||||
logger.info("Starting discord bot: Starting threads")
|
logger.info("Starting discord bot: Starting threads")
|
||||||
WRK_CNT = 0
|
WRK_CNT = 0
|
||||||
for worker in threads:
|
for worker in threads:
|
||||||
|
|||||||
@@ -13,13 +13,15 @@ IN_COMM_Q = Queue()
|
|||||||
awaiting_q = []
|
awaiting_q = []
|
||||||
incoming_q = Queue()
|
incoming_q = Queue()
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
prepped_tracks = {
|
PREPPED_TRACKS = {
|
||||||
"requests" : "",
|
"requests" : "",
|
||||||
"hits" : "",
|
"hit" : "",
|
||||||
"all": "",
|
"all": "",
|
||||||
"prio":"",
|
"priority":"",
|
||||||
"jingles":""
|
"jingles":"",
|
||||||
|
"now_playing":""
|
||||||
}
|
}
|
||||||
|
logger = logging.getLogger("discord")
|
||||||
|
|
||||||
class QueryControl:
|
class QueryControl:
|
||||||
"""
|
"""
|
||||||
@@ -45,6 +47,7 @@ def log_radio_tracks():
|
|||||||
logger.info(request)
|
logger.info(request)
|
||||||
record = json.loads(request.data)
|
record = json.loads(request.data)
|
||||||
logger.info(record)
|
logger.info(record)
|
||||||
|
PREPPED_TRACKS[record[0]] = record[1]
|
||||||
logger.info("DATA RECEIVED")
|
logger.info("DATA RECEIVED")
|
||||||
return jsonify("SUCCESS")
|
return jsonify("SUCCESS")
|
||||||
|
|
||||||
@@ -145,7 +148,7 @@ def scan_incoming():
|
|||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
|
||||||
|
|
||||||
def comm_subroutine(logger):
|
def comm_subroutine():
|
||||||
"""
|
"""
|
||||||
The `comm_subroutine` function starts multiple threads to run different tasks concurrently.
|
The `comm_subroutine` function starts multiple threads to run different tasks concurrently.
|
||||||
|
|
||||||
@@ -169,5 +172,4 @@ def comm_subroutine(logger):
|
|||||||
worker.join()
|
worker.join()
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
logging_client = logging.getLogger(__name__)
|
comm_subroutine()
|
||||||
comm_subroutine(logging_client)
|
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ if platform in ("linux", "linux2"):
|
|||||||
LOGSTORE = "/home/mtuszowski/conjurer/logs/"
|
LOGSTORE = "/home/mtuszowski/conjurer/logs/"
|
||||||
ENCODING = "utf-8"
|
ENCODING = "utf-8"
|
||||||
RADIOLOG_PATH = '/home/pi/Conjurer/radio_log.log'
|
RADIOLOG_PATH = '/home/pi/Conjurer/radio_log.log'
|
||||||
|
PERSISTENCE_PATH = '/home/pi/Conjurer/persistence.log'
|
||||||
|
|
||||||
else:
|
else:
|
||||||
LOGFILE = "/home/pi/Conjurer/discord_mus_service.log"
|
LOGFILE = "/home/pi/Conjurer/discord_mus_service.log"
|
||||||
@@ -41,6 +42,7 @@ if platform in ("linux", "linux2"):
|
|||||||
MUSIC_FOLDER = "/home/pi/RetroPie/mp3/"
|
MUSIC_FOLDER = "/home/pi/RetroPie/mp3/"
|
||||||
PRIORITY_FOLDER = "/home/pi/RetroPie/mp3/Magiczne i chuj/"
|
PRIORITY_FOLDER = "/home/pi/RetroPie/mp3/Magiczne i chuj/"
|
||||||
RADIOLOG_PATH = '/home/pi/Conjurer/radio_log.log'
|
RADIOLOG_PATH = '/home/pi/Conjurer/radio_log.log'
|
||||||
|
PERSISTENCE_PATH = '/home/pi/Conjurer/persistence.log'
|
||||||
|
|
||||||
|
|
||||||
music_file_list = []
|
music_file_list = []
|
||||||
@@ -102,13 +104,35 @@ def scan_tracks():
|
|||||||
logger = logging.getLogger("conjurer_musician")
|
logger = logging.getLogger("conjurer_musician")
|
||||||
|
|
||||||
file = open(RADIOLOG_PATH,'r')
|
file = open(RADIOLOG_PATH,'r')
|
||||||
|
|
||||||
#Find the size of the file and move to the end
|
#Find the size of the file and move to the end
|
||||||
st_results = os.stat(RADIOLOG_PATH)
|
st_results = os.stat(RADIOLOG_PATH)
|
||||||
st_size = st_results[6]
|
st_size = st_results[6]
|
||||||
file.seek(st_size)
|
file.seek(st_size)
|
||||||
|
st_results1 = os.stat(PERSISTENCE_PATH)
|
||||||
|
prev_st_size1 = st_results[6]
|
||||||
|
|
||||||
while 1:
|
while 1:
|
||||||
|
|
||||||
|
st_results1 = os.stat(PERSISTENCE_PATH)
|
||||||
|
st_size1 = st_results1[6]
|
||||||
|
if prev_st_size1 != st_size1:
|
||||||
|
while prev_st_size1 != st_size1:
|
||||||
|
prev_st_size1 = st_size1
|
||||||
|
st_results1 = os.stat(PERSISTENCE_PATH)
|
||||||
|
st_size1 = st_results1[6]
|
||||||
|
time.sleep(0.1)
|
||||||
|
file1 = open(PERSISTENCE_PATH, 'r')
|
||||||
|
lines = file1.readlines()
|
||||||
|
result = ["now_playing", lines[2]]
|
||||||
|
file1.close()
|
||||||
|
returned = requests.post(
|
||||||
|
f"{MAIN_BOT_ADDRESS}{MUSIC_TRACKER}",
|
||||||
|
json=result,
|
||||||
|
timeout=360)
|
||||||
|
logger.info("SENT")
|
||||||
|
logger.info(returned.status_code)
|
||||||
|
logger.info("SEND CONFIRMED")
|
||||||
|
|
||||||
where = file.tell()
|
where = file.tell()
|
||||||
line = file.readline()
|
line = file.readline()
|
||||||
if not line:
|
if not line:
|
||||||
@@ -126,7 +150,7 @@ def scan_tracks():
|
|||||||
logger.info(line) # already has newline
|
logger.info(line) # already has newline
|
||||||
result = ["priority", line]
|
result = ["priority", line]
|
||||||
elif re.match(".*hit.*", line):
|
elif re.match(".*hit.*", line):
|
||||||
logger.info("priority")
|
logger.info("hit")
|
||||||
logger.info(line) # already has newline
|
logger.info(line) # already has newline
|
||||||
result = ["hit", line]
|
result = ["hit", line]
|
||||||
elif re.match(".*all_playlist.*", line):
|
elif re.match(".*all_playlist.*", line):
|
||||||
@@ -142,9 +166,9 @@ def scan_tracks():
|
|||||||
f"{MAIN_BOT_ADDRESS}{MUSIC_TRACKER}",
|
f"{MAIN_BOT_ADDRESS}{MUSIC_TRACKER}",
|
||||||
json=result,
|
json=result,
|
||||||
timeout=360)
|
timeout=360)
|
||||||
logger.info("SENT")
|
logger.info("SENT")
|
||||||
logger.info(returned.status_code)
|
logger.info(returned.status_code)
|
||||||
logger.info("SEND CONFIRMED")
|
logger.info("SEND CONFIRMED")
|
||||||
time.sleep(0.1)
|
time.sleep(0.1)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user