Open rocketinventor opened 7 years ago
I'm pretty new to the code myself, but I got some grasp over it right now. While I've never touched Flask before, I'dd be willing to help out where I can.
@rocketinventor Sounds great, should we do it using django? as i am good at django, i have no prior exposure to flask.
I think Django has a little bit more overhead than we need (unless you think that we need user authentication, etc). Flask is simple and easy to learn.
Most of the work here will be in controlling mpsyt from another program. The main i/o code would be the same no matter which framework we use. I can write up some boiler plate code for Flask if that helps.
As far as the http server goes, all it needs to do is serve up the html and respond to a few API endpoints, right?
@lokendras395 How familiar are you with the mpsyt base code?
@rocketinventor i am very little familiar with mpsyt bascode, but i am familiar with python and django, and previously i have worked on django to create webview for controlling os functionality in storage machines, like mounting unmounting disks, creating zfs snaps, transfering snaps.
@lokendras395 does Django have special functionality for that, or did you just use os.system / subsystem as normal?
The python bits should be the same no matter which framework is used. I can take care of the parts that are unique to Flask. As I said before, Django has a lot of boat that is good for some projects but not others. If you have something fancy on mind (Ie any type of login), we'll stick with Django - let me know
Is there anyone who is familiar with the base code who can assist in modifying the code to support non-interactive commandline usage?
It does already support a form of basic non interactive commandline usage, through comma separated commands as arguments, for examplempsyt "/searchterm, 1, q"
to search, listen to first restult then quit.
Or are you thinking of some other form of commandline usage?
@Razesdark not really. I was hoping for a method that returns something that I can parse easily. The method you described just returns the ascii from the exit screen and no method to get player state. There is no way to get playlist or config info. Also, mpsyt "url https://youtu.be/iS5WZoQGP4I, q"
just exits.
I was hoping for a method that returns something that I can parse easily.
There is no such thing currently. Mpsyt is designed for interactive use; it supports the mpris2 API, but that will only allow retrieving metadata of the current track and playing/pausing.
Ideally mpsyt would have a plugin API to support implementing things like this, but but that never got finished (https://github.com/mps-youtube/mps-youtube/pull/316). Plugin loading of sorts works with that branch, but getting it to work in a sane way was blocked by designing and implementing a good content API (https://github.com/mps-youtube/mps-youtube/pull/423).
If that work was completed (refactoring much of mpsyt) things like this could be done by a plugin that provides a backend replacing the cli backend.
I don't think I can really help with the coding itself at present, but if you have questions about the code, feel free to ask; probably on the #mps-youtube
Freenode channel.
@ids1024 Can you provide some more details on using the mpris2 api? I had trouble getting it to work on my device. Any chance of accessing the que that way, also? That would help a lot.
Besides from those two things, I just need access to the config info (including api key) and saved playlist - everything else can be done client side.
Thanks!
Mpsyt's mpris2 support requires dbus-python
and pygobject
. I've used it with the playerctl
program; you should also be able to find python libraries.
Mpris 2 seems to have APIs for playlists and the tracklist: https://specifications.freedesktop.org/mpris-spec/latest/Track_List_Interface.html, https://specifications.freedesktop.org/mpris-spec/latest/Playlists_Interface.html
But those APIs are not currently implemented by mpsyt. mpris.py has the code for the current mpris2 support.
It may not be ideal, but you should be able to read configuration and playlists from their files directly. See my first comment on #112 for a code snippet to read the playlists.
Retrieving the playlists from the config file is okay, I think.
How much work would it be to implement those API's internally?
I haven't really looking into implementing that part of mpris2 yet. Probably not too hard... the mpris2 thread would have to trigger the main thread playing (perhaps sending a signal).;
Sorry for bumping up. What is the current state of this issue?
I dont think there has been any serious effort to make a MPSYT web interface. However there is a youtube web interface project that is much more active than this called invidious.
Hi, I am thinking about creating a HTTP (web) interface for MPSYT.
To do this, I plan on using Flask to create a web server (using python) and reimplenting the UI with Javascript/HTML/CSS. The client would then communicate with MPSYT via Ajax or web sockets.
As planned, the flow would look like this:
mpsyt server
)The main benefits of this approach is that full functionality is maintained while playing tracks and that anyone on the network can control the player (at the same time).
Any thoughts on this? Any preference on which port number to use? Is there anyone that can assist me with the development of this (I am unfamiliar with the MPSYT code base).
Thanks!