From 1d4c1a2aebe40775bc046f0aca94980ec7f5e466 Mon Sep 17 00:00:00 2001 From: DemonKingSwarn Date: Wed, 21 Feb 2024 22:27:16 +0530 Subject: feat: discord rpc --- yt_music/__yt_music__.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'yt_music/__yt_music__.py') diff --git a/yt_music/__yt_music__.py b/yt_music/__yt_music__.py index 5e19c2d..9d8c0a3 100644 --- a/yt_music/__yt_music__.py +++ b/yt_music/__yt_music__.py @@ -3,7 +3,9 @@ import re import subprocess import platform import os +import time +from pypresence import Presence import httpx import fzf @@ -12,6 +14,11 @@ headers = { } +start = int(time.time()) +client_id = "1075791459409723472" +RPC = Presence(client_id) +RPC.connect() + client = httpx.Client(headers=headers, timeout=None) base_url = "https://vid.puffyan.us" @@ -72,6 +79,15 @@ def download(video_id, video_title): def play_loop(video_id, video_title): + RPC.update( + large_image = f"http://img.youtube.com/vi/{video_id}/0.jpg", + large_text = "haha checkmate spotify plebs", + small_image = "youtube_music_icon_svg", + small_text = "yt-music", + start = start, + details = f"{video_title} - loop", + ) + args = [ MPV_EXECUTABLE, f"https://music.youtube.com/watch?v={video_id}", @@ -87,6 +103,15 @@ def play_loop(video_id, video_title): def play(video_id, video_title): + RPC.update( + large_image = f"http://img.youtube.com/vi/{video_id}/0.jpg", + large_text = "haha checkmate spotify plebs", + small_image = "youtube_music_icon_svg", + small_text = "yt-music", + start = start, + details = video_title, + ) + args = [ MPV_EXECUTABLE, f"https://music.youtube.com/watch?v={video_id}", -- cgit v1.1