From 1d4c1a2aebe40775bc046f0aca94980ec7f5e466 Mon Sep 17 00:00:00 2001 From: DemonKingSwarn Date: Wed, 21 Feb 2024 22:27:16 +0530 Subject: feat: discord rpc --- pyproject.toml | 3 ++- yt_music/__version__.py | 2 +- yt_music/__yt_music__.py | 25 +++++++++++++++++++++++++ 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 79f1677..d697b1f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api" [tool.poetry] name = "yt-music" -version = "0.0.3" +version = "0.0.4" description = "A command line YouTube Music client." authors = ["DemonKingSwarn "] license = "GPLv3" @@ -15,6 +15,7 @@ python = "^3.10" httpx = "0.23.0" krfzf-py = "^0.0.4" yt-dlp = "^2023.12.30" +pypresence = "4.3.0" [tool.poetry.dev-dependencies] diff --git a/yt_music/__version__.py b/yt_music/__version__.py index 24d9284..017a3e5 100644 --- a/yt_music/__version__.py +++ b/yt_music/__version__.py @@ -1 +1 @@ -__core__ = "0.0.3" +__core__ = "0.0.4" 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