Coder Social home page Coder Social logo

cniw / mpv-discordrpc Goto Github PK

View Code? Open in Web Editor NEW
133.0 4.0 10.0 2.78 MB

Discord Rich Presence integration for mpv Media Player

License: MIT License

Lua 70.37% Shell 19.73% Batchfile 5.06% Python 4.84%
mpv-discordrpc mpv discord discord-rich-presence discord-rpc rich-presence luajit lua lua-script mpv-media-player

mpv-discordrpc's Introduction

Discord Rich Presence intergation for mpv Media Player


This is alternative version, edited from mpv-discordRPC. I add metadata tags (Title, Artist and Album) support for 'details' and I use status-line for 'state'. I use 'elapsed' time mode when idle, while when playing, paused, and buffering use 'left' time mode. I add support and installer script for Linux, Mac and Windows. I also add custom configuration file and new features: info, cover art, url detections, and active/inactive toggle.

For more description read below.


Previews

Description Image
Idle Idle
Playing Playing
Paused Paused
Info: playlist and loop Info: playlist and loop
Cover art Cover art
YouTube playing YouTube playing
Crunchyroll paused Crunchyroll paused
SoundCloud playing SoundCloud playing
LISTEN.moe paused LISTEN.moe paused

Used softwares

  1. Provided by user: mpv, Discord
  2. Included: Discord RPC, status-line, lua-discordRPC
  3. Optional: Python, pypresence

Downloads

  • Latest Releases download
  • All Releases download

Installation

  1. For Linux, installing just run install-linux.sh on terminal.
  2. For Windows, installing just run install-win.bat by double-clicking it.
  3. For Mac, installing just run install-osx.sh on terminal.

Settings

Just edit mpv_discordRPC.conf file in script-opts folder. Now Available 2 rpc_wrapper option, choose one. Example:

  • Configuration (A) rpc_wrapper and periodic_timer

    rpc_wrapper=lua-discordRPC
    periodic_timer=1
    
  • Configuration (B) rpc_wrapper and periodic_timer

    rpc_wrapper=python-pypresence
    periodic_timer=3
    

Setting to show playlist info and loop info. Example:

  • Configuration playlist_info and loop_info

    playlist_info=yes
    loop_info=yes
    

Setting to show cover art. Example:

  • Configuration cover_art

    cover_art=yes
    

Setting to active/inactive toggle the Discord RPC and the start states. Example:

  • Configuration active and key_toggle

    active=yes
    key_toggle=D
    

To use rpc_wrapper=lua-discordRPC, Important LuaJIT on mpv

Check LuaJIT, because it has FFI Library and it needed by lua-discordRPC.

  1. For Linux

    • Make sure your mpv binary linked to luajit~~ not lua~~ library.

      ldd $(which mpv) | grep luajit
      libluajit-5.1.so.2 => /usr/lib/x86_64-linux-gnu/libluajit-5.1.so.2 (0x00007f32e9a83000)
    • If it's dynamic build while it's static build you can check with

      mpv -v -V | sed -rn 's/.*(luajit).*/\1/p'
      luajit
  2. For Windows (Don't worry)

    • You can skip this because available mpv Windows build by lachs0r and shinchiro already use LuaJIT and it static build which configured with --enable-static-build.
  3. For Mac (So sad)

    • Until now, LuaJIT still have problem on Mac OS X. Also build mpv with LuaJIT on Mac OS X (read mpv issue #1110), it maybe can build successfully but still can't load LuaJIT properly when run mpv (read mpv issue #5205). You can check with otool command.

To use rpc_wrapper=python-pypresence, Important to install pypresence

Support Mac, Windows, and Linux because can use with Lua or LuaJIT.

  1. Install Python >=3.5 because this version has asyncio library which needed by pypresence.
  2. Install pypresence pip install pypresence or pip install https://github.com/qwertyquerty/pypresence/archive/master.zip use pip3 instead of pip if Python 2 still installed on your old machine.

You may want to check again, run command mpv -v -V and find luajit or lua word on the line which beginning with [cplayer] List of enabled features: for Mac, Windows or Linux.


Testing

  1. Open your Discord then,
  2. Open your mpv then,
  3. Back to Discord and then check your profile.

Good Luck and have a nice day.

Feedback: If you have question, problem or request, please make new issue or contact me wachidadinugroho#7674 via Discord.

mpv-discordrpc's People

Contributors

cniw avatar joshuawprice avatar mrniceforest avatar naxay07 avatar r33int avatar wxllow avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

mpv-discordrpc's Issues

Doesn't work with Apple Silicon Macs

When trying to use on M1 MacBook Air, I get this error:

[mpv_discordRPC] Lua error: ...wl/.config/mpv/scripts/mpv-discordRPC/lua-discordRPC.lua:2: dlopen(libdiscord-rpc.dylib, 0x0005): tried: '/usr/lib/swift/libdiscord-rpc.dylib' (no such file), '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/libdiscord-rpc.dylib' (no such file), 'libdiscord-rpc.dylib' (no such file), '/usr/local/lib/libdiscord-rpc.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e')), '/usr/lib/libdiscord-rpc.dylib' (no such file), '/Users/wl/libdiscord-rpc.dylib' (no such file)

Cover art doesn't work.

Hi, it seems that after getting the basic functionalities of this to work, the cover art doesn't show up for any of my songs.

Recent mpv changes

Hi,

with the recent changes in MPV regarding scripts, this stopped working with the following errors (tested with mpv-x86_64-20200202-git-77a74d9):

   cplayer: Cannot find main.* for any supported scripting backend in: C:/Program Files/MPV/scripts/mpv-discordRPC

mpv_discordRPC: Discord Rich Presence integration for mpv Media Player
mpv_discordRPC: Upstream: https://github.com/cniw/mpv-discordRPC
mpv_discordRPC: Version: 1.4.1

mpv_discordRPC:
mpv_discordRPC: stack traceback:
mpv_discordRPC:         C:/Program Files/MPV/scripts/mpv-discordRPC.lua:126: in function 'cb'
mpv_discordRPC:         mp.defaults:346: in function 'process_timers'
mpv_discordRPC:         mp.defaults:506: in function 'dispatch_events'
mpv_discordRPC:         mp.defaults:479: in function <mp.defaults:478>
mpv_discordRPC:         [C]: at 0x00d18430
mpv_discordRPC:         [C]: at 0x00d17b00
mpv_discordRPC: Lua error: C:/Program Files/MPV/scripts/mpv-discordRPC.lua:126: module 'mpv-discordRPC.catalogs' not found:
mpv_discordRPC:         no field package.preload['mpv-discordRPC.catalogs']
mpv_discordRPC:         no file '.\mpv-discordRPC\catalogs.lua'
mpv_discordRPC:         no file 'C:\Program Files\MPV\lua\mpv-discordRPC\catalogs.lua'
mpv_discordRPC:         no file 'C:\Program Files\MPV\lua\mpv-discordRPC\catalogs\init.lua'
mpv_discordRPC:         no file '.\mpv-discordRPC\catalogs.dll'
mpv_discordRPC:         no file 'C:\Program Files\MPV\mpv-discordRPC\catalogs.dll'
mpv_discordRPC:         no file 'C:\Program Files\MPV\loadall.dll'
mpv_discordRPC:         no file '.\mpv-discordRPC.dll'
mpv_discordRPC:         no file 'C:\Program Files\MPV\mpv-discordRPC.dll'
mpv_discordRPC:         no file 'C:\Program Files\MPV\loadall.dll'

This however can be easily fixed.
The files from "scripts\mpv-discordRPC" just need to be placed into the directory "lua\mpv-discordRPC" (or as above, in any other of the named directories, but the "lua" ones seems the most elegant, however the "lua" directory needs to be created if not already present).
Perhaps this can be considered with the installer script.

Segmentation fault on mpv while using the mpv-discordRPC

I have been getting segmentation fault pretty much after playing a song for 5-10 min

Which I didn't really get before.

mpv --no-video --loop STUDY\ WITH\ ME\ 24\ HOURS\ ๐Ÿ’ง\ lofi\ Music\ ๏ฝœ\ Lofi\ Study\ ๏ฝœ\ Chill\ music\ ~\ 35\ min\ study\ x\ 15\ min\ chill\ [Tq7523sJc6I].opus
[mpv_discordRPC] Discord Rich Presence integration for mpv Media Player
[mpv_discordRPC] Upstream: https://github.com/cniw/mpv-discordRPC
[mpv_discordRPC] Version: 1.4.1-UNKNOWN
(+) Audio --aid=1 --alang=eng 'STUDY WITH ME 24 HOURS ๐Ÿ’ง lofi Music | Lofi Study | Chill music ~ 35 min study x 15 min chill' (opus 2ch 48000Hz)
File tags:
Artist: Mimi Lofi Chill
Comment: https://www.youtube.com/watch?v=Tq7523sJc6I
Date: 20230114
Title: STUDY WITH ME 24 HOURS ๐Ÿ’ง lofi Music | Lofi Study | Chill music ~ 35 min study x 15 min chill
AO: [pipewire] 48000Hz stereo 2ch floatp
zsh: segmentation fault (core dumped) mpv --no-video --loop

lua error

Can't seem to get it working anymore. Following the install script and editing the config to use pypresence gives this error:

[mpv_discordRPC_lua_discordRPC]
[mpv_discordRPC_lua_discordRPC] stack traceback:
[mpv_discordRPC_lua_discordRPC] [C]: in function 'require'
[mpv_discordRPC_lua_discordRPC] ...in/.config/mpv/scripts/mpv-discordRPC_lua-discordRPC.lua:1: in main chunk
[mpv_discordRPC_lua_discordRPC] [C]: in ?
[mpv_discordRPC_lua_discordRPC] [C]: in ?
[mpv_discordRPC_lua_discordRPC] Lua error: ...in/.config/mpv/scripts/mpv-discordRPC_lua-discordRPC.lua:1: module 'ffi' not found:
[mpv_discordRPC_lua_discordRPC] no field package.preload['ffi']
[mpv_discordRPC_lua_discordRPC] no file '/usr/local/share/lua/5.2/ffi.lua'
[mpv_discordRPC_lua_discordRPC] no file '/usr/local/share/lua/5.2/ffi/init.lua'
[mpv_discordRPC_lua_discordRPC] no file '/usr/local/lib/lua/5.2/ffi.lua'
[mpv_discordRPC_lua_discordRPC] no file '/usr/local/lib/lua/5.2/ffi/init.lua'
[mpv_discordRPC_lua_discordRPC] no file '/usr/share/lua/5.2/ffi.lua'
[mpv_discordRPC_lua_discordRPC] no file '/usr/share/lua/5.2/ffi/init.lua'
[mpv_discordRPC_lua_discordRPC] no file './ffi.lua'
[mpv_discordRPC_lua_discordRPC] no file '/home/lain/.config/mpv/scripts/ffi.lua'
[mpv_discordRPC_lua_discordRPC] no file '/usr/local/lib/lua/5.2/ffi.so'
[mpv_discordRPC_lua_discordRPC] no file '/usr/lib/x86_64-linux-gnu/lua/5.2/ffi.so'
[mpv_discordRPC_lua_discordRPC] no file '/usr/lib/lua/5.2/ffi.so'
[mpv_discordRPC_lua_discordRPC] no file '/usr/local/lib/lua/5.2/loadall.so'
[mpv_discordRPC_lua_discordRPC] no file './ffi.so'

Cover art leaking stream URL

When hovering over the cover art for a web stream, it shows the URL, and afaik there is no way to hide that.
It is usually not a big deal but for my IPTV provider it leaks my login information. I know it's a bad design on their part but might be useful in other scenarios as well.
Image illustrating: example

Time left continues to decrease when the mpv is paused

On Windows 10,
mpv version 0.32.0-288-gee70e8ce50
and mpv-discordRPC version 1.4.1-UNKNOWN
I did not change any settings after installation.

When mpv is paused, Discord presence updates properly to show that the player is paused, but the remaining time continues ticking down, for around 15 seconds, after which, it jumps back to the proper time and continues ticking down.

e.g.:

  • I paused a movie with mpv showing 04:22:47 left;
  • Discord presence shows the paused icon but the "xx:xx:xx left" text continues ticking down
  • Once the timer reaches "04:22:31 left", after one second, it jumps back to "04:22:45 left" and continues this countdown loop.

Everything else works fine i.e. the current timestamp ("AV:") does not change while the time left counter is ticking down.

Here's a screen recording from the Discord desktop app to better illustrate my issue (username and tag blurred for privacy):

mpv-discordRPC

module 'ffi' not found

[mpv_discordRPC] Discord Rich Presence integration for mpv Media Player 
[mpv_discordRPC] Upstream: https://github.com/cniw/mpv-discordRPC 
[mpv_discordRPC] Version: 1.4.1-UNKNOWN 
 (+) Video --vid=1 (*) (vp9 1920x1080 29.970fps)
 (+) Audio --aid=1 --alang=eng (*) (aac 2ch 44100Hz)
AO: [pulse] 44100Hz stereo 2ch float
[mpv_discordRPC] 
[mpv_discordRPC] stack traceback:
[mpv_discordRPC] 	[C]: in function 'require'
[mpv_discordRPC] 	...nd/.config/mpv/scripts/mpv-discordRPC/lua-discordRPC.lua:1: in main chunk
[mpv_discordRPC] 	[C]: in function 'require'
[mpv_discordRPC] 	[string "/home/uend/.config/mpv/scripts/mpv-discordRPC..."]:228: in function 'cb'
[mpv_discordRPC] 	mp.defaults:351: in function 'process_timers'
[mpv_discordRPC] 	mp.defaults:520: in function 'dispatch_events'
[mpv_discordRPC] 	mp.defaults:493: in function <mp.defaults:492>
[mpv_discordRPC] 	[C]: in ?
[mpv_discordRPC] 	[C]: in ?
[mpv_discordRPC] Lua error: ...nd/.config/mpv/scripts/mpv-discordRPC/lua-discordRPC.lua:1: module 'ffi' not found:
[mpv_discordRPC] 	no field package.preload['ffi']
[mpv_discordRPC] 	no file '/home/uend/.config/mpv/scripts/mpv-discordRPC/ffi.lua'
[mpv_discordRPC] 	no file '/usr/local/share/lua/5.2/ffi.lua'
[mpv_discordRPC] 	no file '/usr/local/share/lua/5.2/ffi/init.lua'
[mpv_discordRPC] 	no file '/usr/local/lib/lua/5.2/ffi.lua'
[mpv_discordRPC] 	no file '/usr/local/lib/lua/5.2/ffi/init.lua'
[mpv_discordRPC] 	no file '/usr/share/lua/5.2/ffi.lua'
[mpv_discordRPC] 	no file '/usr/share/lua/5.2/ffi/init.lua'
[mpv_discordRPC] 	no file '/usr/local/lib/lua/5.2/ffi.so'
[mpv_discordRPC] 	no file '/usr/lib/x86_64-linux-gnu/lua/5.2/ffi.so'
[mpv_discordRPC] 	no file '/usr/lib/lua/5.2/ffi.so'
[mpv_discordRPC] 	no file '/usr/local/lib/lua/5.2/loadall.so'

Tried several things, couldn't get the script working.

Manjaro Linux 5.6.10-3
mpv 0.32.0
Lua 5.3.5

Running this script with -v, i see the following error...

[cplayer] Can't load unknown script: /home/user/.config/mpv/scripts/mpv-discordRPC

The scripts are correctly there. I tried referencing main.lua directly using --script=... but that ended up failing to import the catalogs.lua script.

Then I tried moving catalogs.lua and the other lua script into the PWD, I had the config file point to python, but for some reason it wasn't respecting the scripts-opt folder and tried to run the lua script (which failed because I don't have ffi installed).

I was wondering if this was related to mpv-player/mpv#7399

Starts but doesn't send to discord

[mpv_discordRPC] Discord Rich Presence integration for mpv Media Player
[mpv_discordRPC] Upstream: https://github.com/cniw/mpv-discordRPC
[mpv_discordRPC] Version: 1.4.1-UNKNOWN
(+) Video --vid=1 () (h264 1520x1080 23.976fps)
(+) Audio --aid=1 --alang=jpn (
) (aac 2ch 48000Hz)
File tags:
Title: [Kagura] Serial Experiments Lain - 01 [BDRip 1520x1080 x264 Hi10P FLAC]
AO: [pulse] 48000Hz stereo 2ch float
VO: [gpu] 1520x1080 yuv420p
AV: 00:01:39 / 00:23:56 (7%) A-V: 0.000042 Vb: 2.602 mbps Ab: 161 kbps

After recent changes I get this error messages in console

  • mpv-x86_64-20200426-git-640db1e
  • mpv-discordRPC-1.4.1-UNKNOWN-win

Log (colorized):

- Can't load unknown script: C:\Users\X4\AppData\Roaming/mpv/scripts/mpv-discordRPC_pypresence.py
! [mpv_discordRPC] script-opts/mpv_discordRPC.conf:21 unknown key mpv_version, ignoring
[mpv_discordRPC] Discord Rich Presence integration for mpv Media Player
[mpv_discordRPC] Upstream: https://github.com/cniw/mpv-discordRPC
[mpv_discordRPC2] Discord Rich Presence integration for mpv Media Player
[mpv_discordRPC] Version: 1.4.1
[mpv_discordRPC2] Upstream: https://github.com/cniw/mpv-discordRPC
[mpv_discordRPC2] Version: 1.4.1-UNKNOWN

I have no issues with using python version (tried it as well before), but I still use lua, however mpv now after update throwing errors about this file.
Also it have some problems with mpv_version variable, may be need to rename it?

intermittent issue cause mpv to hang on exit

Hi, im currently having a issue where mpv hangs on exit sometimes, I have only just opened GDB to see where it is getting stuck and it seems to be on the closing on the RPC connection in the discord provided RPC library. I am not sure if this is a upstream issue or an issue with how mpv-discordRPC tells the libary to quit

image

ImportError: No module named pypresence

Hello,
I am trying to use this on a fresh install of Kubuntu 19.10 but for some reason pypresence is giving me issues. When running mpv from the terminal, I can see the script is giving this error over and over:
Traceback (most recent call last): File "/home/user/.config/mpv/scripts/mpv-discordRPC/python-pypresence.py", line 6, in <module> import pypresence ImportError: No module named pypresence
However, pypresence IS installed. Python 3 is at version 3.7.5. and pip3 list shows pypresence 3.3.2 is there. Further, if I open a terminal and manually run python3 and then import pypresence, it works just fine.

I need help

When using a custom appID and state, every 15 seconds the status will go back to the default title and (Playing) state, and then turn back after a second. It's super frustrating, so if anyone has a fix please let me know.

module 'ffi' not found

I'm having trouble running this, when i try to run mpv, it shows me this:

[mpv_discordRPC] Lua error: ...su/.config/mpv/scripts/mpv-discordRPC/lua-discordRPC.lua:1: module 'ffi' not found: [mpv_discordRPC] no field package.preload['ffi'] [mpv_discordRPC] no file '/home****/.config/mpv/scripts/mpv-discordRPC/ffi.lua' [mpv_discordRPC] no file '/usr/share/lua/5.2/ffi.lua' [mpv_discordRPC] no file '/usr/share/lua/5.2/ffi/init.lua' [mpv_discordRPC] no file '/usr/lib/lua/5.2/ffi.lua' [mpv_discordRPC] no file '/usr/lib/lua/5.2/ffi/init.lua' [mpv_discordRPC] no file '/usr/lib/lua/5.2/ffi.so' [mpv_discordRPC] no file '/usr/lib/lua/5.2/loadall.so'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.