Compare commits
No commits in common. "4fd92f7834d8ffede3cb3a18530860ecf035e077" and "404328b07c20c88c1c05ebbcf25c6986553eb9df" have entirely different histories.
4fd92f7834
...
404328b07c
4 changed files with 6 additions and 17 deletions
|
@ -1,8 +1,5 @@
|
||||||
TOKEN=""
|
TOKEN=""
|
||||||
PO_TOKEN=""
|
|
||||||
COOKIES_FILE=""
|
|
||||||
GUILD_ID=""
|
GUILD_ID=""
|
||||||
QUEUE_PATH=""
|
|
||||||
MAX_MIN="8"
|
MAX_MIN="8"
|
||||||
MAX_QUEUE="5"
|
MAX_QUEUE="5"
|
||||||
ALLOW_SKIP="TRUE"
|
ALLOW_SKIP="TRUE"
|
||||||
|
|
5
.gitignore
vendored
5
.gitignore
vendored
|
@ -31,10 +31,7 @@ share/python-wheels/
|
||||||
*.egg
|
*.egg
|
||||||
*.mp4
|
*.mp4
|
||||||
*.vtt
|
*.vtt
|
||||||
cookies*
|
|
||||||
testing/
|
testing/
|
||||||
*.db
|
|
||||||
next*
|
|
||||||
MANIFEST
|
MANIFEST
|
||||||
|
|
||||||
# PyInstaller
|
# PyInstaller
|
||||||
|
@ -132,7 +129,7 @@ celerybeat.pid
|
||||||
|
|
||||||
# Environments
|
# Environments
|
||||||
.env
|
.env
|
||||||
.*venv
|
.venv
|
||||||
env/
|
env/
|
||||||
venv/
|
venv/
|
||||||
ENV/
|
ENV/
|
||||||
|
|
13
newbot.py
13
newbot.py
|
@ -19,8 +19,7 @@ import sqlite3
|
||||||
|
|
||||||
if len(sys.argv) > 1:
|
if len(sys.argv) > 1:
|
||||||
if sys.argv[1] == "--clear-queue":
|
if sys.argv[1] == "--clear-queue":
|
||||||
if os.path.isfile(os.getenv("QUEUE_PATH","queue.db")):
|
os.remove("queue.db")
|
||||||
os.remove(os.getenv("QUEUE_PATH","queue.db"))
|
|
||||||
print("Queue cleared!")
|
print("Queue cleared!")
|
||||||
|
|
||||||
load_dotenv()
|
load_dotenv()
|
||||||
|
@ -35,7 +34,7 @@ vid_dir = Path(temp_dir.name)
|
||||||
download_dir = TemporaryDirectory()
|
download_dir = TemporaryDirectory()
|
||||||
full_dl_dir = Path(download_dir.name)
|
full_dl_dir = Path(download_dir.name)
|
||||||
vid_details = {"title": "", "channel": ""}
|
vid_details = {"title": "", "channel": ""}
|
||||||
con = sqlite3.connect(os.getenv("QUEUE_PATH","queue.db"), check_same_thread=False)
|
con = sqlite3.connect("queue.db", check_same_thread=False)
|
||||||
cur = con.cursor()
|
cur = con.cursor()
|
||||||
|
|
||||||
def countuser(usrid):
|
def countuser(usrid):
|
||||||
|
@ -81,9 +80,6 @@ ydl_opts = {
|
||||||
'match_filter': video_check,
|
'match_filter': video_check,
|
||||||
'hls_prefer_native': True,
|
'hls_prefer_native': True,
|
||||||
'extract_flat': 'discard_in_playlist',
|
'extract_flat': 'discard_in_playlist',
|
||||||
'cookiefile': f'{os.getenv("COOKIES_FILE")}',
|
|
||||||
'extractor_args': {'youtube': {'player_client': ['web', 'default'],
|
|
||||||
'po_token': [f'web+{os.getenv("PO_TOKEN")}']}},
|
|
||||||
'format': 'bestvideo[height<=1080][vcodec!*=av01][ext=mp4]+bestaudio[abr<=256][ext=m4a]/best[ext=mp4]/best',
|
'format': 'bestvideo[height<=1080][vcodec!*=av01][ext=mp4]+bestaudio[abr<=256][ext=m4a]/best[ext=mp4]/best',
|
||||||
'fragment_retries': 10,
|
'fragment_retries': 10,
|
||||||
'noplaylist': True,
|
'noplaylist': True,
|
||||||
|
@ -157,7 +153,7 @@ def download_video(index):
|
||||||
sleep(2) #allow ytdlp to fully cleanup
|
sleep(2) #allow ytdlp to fully cleanup
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print("handling youtube exception")
|
print("handling youtube exception")
|
||||||
if "Sign in to confirm" in str(e) or "forbidden" in str(e).lower():
|
if "Sign in to confirm" in str(e):
|
||||||
print("youtube ban detected")
|
print("youtube ban detected")
|
||||||
#This is the worst possible case and therefore all activity must halt
|
#This is the worst possible case and therefore all activity must halt
|
||||||
obs.set_current_program_scene("banned")
|
obs.set_current_program_scene("banned")
|
||||||
|
@ -268,7 +264,7 @@ async def stats(inter: disnake.AppCmdInter):
|
||||||
message = message + f"Link: <{queue[0]}>\n"
|
message = message + f"Link: <{queue[0]}>\n"
|
||||||
playing = obs.get_media_input_status("player")
|
playing = obs.get_media_input_status("player")
|
||||||
message = message + f"Video Duration: {str(datetime.timedelta(seconds=(round(playing.media_cursor/1000))))}/{str(datetime.timedelta(seconds=(round(playing.media_duration/1000))))}\n"
|
message = message + f"Video Duration: {str(datetime.timedelta(seconds=(round(playing.media_cursor/1000))))}/{str(datetime.timedelta(seconds=(round(playing.media_duration/1000))))}\n"
|
||||||
if inter.permissions.moderate_members:
|
if inter.permissions.moderate_members and not (os.getenv("PERMANENT_MAX_QUEUE","FALSE") == "TRUE"):
|
||||||
res = cur.execute(f"SELECT user FROM queue WHERE hasplayed = true AND link = '{queue[0]}'")
|
res = cur.execute(f"SELECT user FROM queue WHERE hasplayed = true AND link = '{queue[0]}'")
|
||||||
res = res.fetchall() #We can't gaurentee the result so just show likely possibilites
|
res = res.fetchall() #We can't gaurentee the result so just show likely possibilites
|
||||||
message = message + f"Users who have queued this video: "
|
message = message + f"Users who have queued this video: "
|
||||||
|
@ -605,5 +601,4 @@ bot.run(os.getenv("TOKEN"))
|
||||||
print("cleaning up tempdir")
|
print("cleaning up tempdir")
|
||||||
temp_dir.cleanup()
|
temp_dir.cleanup()
|
||||||
download_dir.cleanup()
|
download_dir.cleanup()
|
||||||
con.close()
|
|
||||||
obs.set_current_program_scene("nosignal")
|
obs.set_current_program_scene("nosignal")
|
|
@ -10,8 +10,8 @@ pkgs.mkShell {
|
||||||
pkgs.python311Packages.python-dotenv
|
pkgs.python311Packages.python-dotenv
|
||||||
pkgs.python311Packages.venvShellHook
|
pkgs.python311Packages.venvShellHook
|
||||||
pkgs.ffmpeg
|
pkgs.ffmpeg
|
||||||
|
pkgs.icewm
|
||||||
pkgs.discord
|
pkgs.discord
|
||||||
pkgs.mpv
|
|
||||||
];
|
];
|
||||||
venvDir = "./.venv";
|
venvDir = "./.venv";
|
||||||
}
|
}
|
Loading…
Reference in a new issue