Monday, 8 July 2013

GSoC - Weeks 1, 2 & 3

Hey :)
As I mentioned in my previous post, I'm working on revamping Amarok's scripting interface for GSoC 2013. Here's an update on what I've been working on these past 3 weeks.

1. Script Termination

Amarok now checks running scripts, and offers to terminate long running/ unresponsive ones after a 5 second duration, so you can now kill unresponsive scripts instead of having Amarok freeze on you.Here's a screenshot of the popup:


Yes, the popup's ugly. It's going to be a simple modal dialog instead, as Mark [my mentor, Amarok founder] suggested.

2. Collection Management

Now, script writers have access to Amarok's underlying collection management. Scripts can now access collections, query them using simple collection browser like queries, and copy/ move files among them.

3.Script Console

I've now been working on a new script console- here's a screenshot:



Hovering over the running script , you now get controls for stopping the script, and clearing it. Scripts are automatically saved to the disk (with random names and other plugin specs for now), and you can optionally have them cleared from the disk too.

Double clicking on the script, opens up the editor, and like the main editor on the left. It is a standard katepart, so you get cool features like syntax highlighting, word completion and auto-indentation.

This is quite crude a prototype right now, though. If approved, I'll hopefully be able to work on a code completion model, so you can have auto-completion for Amarok Script. This does, however, pose some difficulties, but they can hopefully be sorted out with the help of my mentor and the kparts team.

There's also two bug fixes- a fix for the crashes on disabling Free Music Charts, and a fix for crashes that may occur when the dependencies for a script weren't listed in its specs.

PS - My apologies for not having been regular with my blog updates- there isn't really much I can say in my defense, except for the assurance that I'll be more regular from now on.

PPS-
Again, I repeat:
Amarok Script Authors please provide feedback on what you'd like to see in the scripting interface here [comments on the blog are okay, too] so I can work on implementing it.

12 comments:

  1. "Amarok now checks running scripts, and offers to terminate long running/ unresponsive ones"
    Good idea. The popup message is maybe a bit too technical, something like "not responding" seems more apropriate to me.

    ReplyDelete
    Replies
    1. You're right, "Not Responding" does seem more succint, though I wonder how well that translates over to other languages.

      Delete
  2. Some applications will launch a web server and it would be interesting to have a quick way to restart an application after changes.

    Also, it would be interesting to have a repl for quick tests as well as being able to run a selected snippet only and it would be awesome if we could have some real debugger in the editor ;)

    ReplyDelete
    Replies
    1. You can simply click on the little play button you get over the script after editing to relaunch it, gotta be fast enough. A repl sounds great, and would be trivial to add too :) I'm not sure about the debugger, though simple syntax checking and highlighting shouldn't be hard.
      As far as launching snippets is concerned, why not just copy-paste it into the console?

      Delete
  3. Modal dialogs are the worst!

    Maybe just kill the script with an easy-to-ignore option to restart it and not kill it next time. Also wouldn't be unreasonable to just silently kill such scripts.

    ReplyDelete
    Replies
    1. Finally, somebody who agrees with me ;)
      Maybe we can have a timer, like in the longMessages, and the script's auto-killed after that.

      Delete
  4. Ooh, code completion for random languages in KatePart... I'm definitely interested in that. It's been on my "I want to do that one day" list for a long time ;)
    Will you be at akademy? Maybe we can talk about it there.

    Cheers,
    Sven

    ReplyDelete
    Replies
    1. Not going to Akademy :(
      I did try the code completion thingy though, I hardcoded a bunch of the scripting API calls. It's trivial introspecting my QtScript API calls at runtime and generating a list, but I doubt that's a very good way of going about it. Quite a bit of it is copy pasted from kate sources, and the popup looks broken, though it works fine.
      I didn't wanna spend too much time on it until getting markey's approval. Here's the code(warning- ugly) for the completion model:
      http://paste.kde.org/792968/

      Delete
  5. Hi Anmol,

    as one of the authors of the Rating Statistics addon ( http://kde-apps.org/content/show.php/Rating+Statistics?content=100541 ) I had a hard time getting the path to the album cover for a given song.
    The problem was not querying the database but rather the interpretation of the data. For some songs the database holds a strange MD5 hash, for others an even stranger filename and whatever.
    I don't know if this is already inclueded in the "access to Amarok's underlying collection management" you mentioned. If not, regard this as a wish :)

    ReplyDelete
  6. I doubt the url is guaranteed to be local, but a hash does sound weird. The current state probably isn't any different though, I haven't touched the scripting track prototypes (not that the problem lies there, it's just a wrapper).

    Have you tried using .imagePixmap( ) instead?

    ReplyDelete
    Replies
    1. As far as I can see from the API documentation, you can get a track prototype (and therefore a .imagePixmap() method) only for the current track. But for Rating Statistics, we need the image for an arbirary track.

      Delete
  7. I just had a look at your script. You're right, such queries aren't possible with the the query maker I exposed, not yet at least. Lemme see what I can do about it :)

    ReplyDelete