Working with Python (Google Music API)

This forum is for questions / discussions regarding development of addons / tweaks for MediaMonkey for Windows 4.

Moderators: Gurus, Addon Administrators

wormywyrm
Posts: 73
Joined: Tue Jan 12, 2010 4:40 pm

Working with Python (Google Music API)

Post by wormywyrm »

I am working on a playlist/library uploader that will sync mediamonkey and google music, but I may need some help.

Simon Weber recently released an unofficial API for google music at https://github.com/simon-weber/Unoffici ... -Music-API

The API is written in python, so I just downloaded python and will be working with it for the first time. What I could really use advice on is how to integrate mediamonkey and python. So far this is all the information I was able to find:

http://www.mediamonkey.com/wiki/index.p ... _scripting
http://mediamonkey.com/wiki/index.php/P ... t_handling

I'm not sure if it is going to be enough to figure out everything based on. Could allow me to see an example of their python plug-in or point me in the right direction?
MM to Grooveshark Playlist Sync w/ MonkeyShark.
http://lysle.net/projects/monkeyshark.php
Thanasis
Posts: 84
Joined: Sun Aug 28, 2011 2:53 am

Re: Working with Python (Google Music API)

Post by Thanasis »

If nothing else works there is a loose alternative....

Using vbscript write all the variables in a text file and then call your Python Script (from within .vbs) to read the variables and execute the calculations !!!!
mcow
Posts: 834
Joined: Sun Sep 21, 2008 9:35 pm
Location: Cupertino, California

Re: Working with Python (Google Music API)

Post by mcow »

There are different things you'll need to do depending on how the script is run. Those two pages you are looking at should be enough to get you accessing MM from Python code. If you're just going to launch the script in parallel to MM (from a desktop icon, say) there isn't much else you need to do.

To launch a Python script from within MM, I use this technique:

Code: Select all

Sub StartPyScript
  Set WshShell = CreateObject("WScript.Shell")
  Set oFSO = CreateObject("Scripting.FileSystemObject")
  ' Example: path to the script, in the MM Scripts folder... but could be anywhere
  path = SDB.ScriptsPath & "PyScript.pyw"
  ' Launch the script...
  paths = oFSO.GetFile(path).ShortPath
  WshShell.Run paths
End Sub
You'll need the pywin32 package for MM access, which means you'll have the PythonWin IDE to work in. With that, you can try various bits of code interactively; and if you type the name of a MM interface object, and then a dot (.), PythonWin will put up a code-completion window that shows all the accessible member elements. Select one and <tab> to enter that element name as if you'd typed it. (Note that the window also shows a handful of members that you can't actually access: CLSID, AddRef, GetTypeInfo. These are elements of the COM interface that, as a rule, you don't need.)
Thanasis
Posts: 84
Joined: Sun Aug 28, 2011 2:53 am

Re: Working with Python (Google Music API)

Post by Thanasis »

Yes but I think mcow's solution will invoke the Windows UAC message !!!
simon_weber

Re: Working with Python (Google Music API)

Post by simon_weber »

Hey, all. I'm Simon - the one who made the linked api.

I just posted in another thread about creating a syncing tool: http://www.mediamonkey.com/forum/viewto ... 83#p335183. Head over there to check it out; I'm fairly confident my plan will work.
mcow
Posts: 834
Joined: Sun Sep 21, 2008 9:35 pm
Location: Cupertino, California

Re: Working with Python (Google Music API)

Post by mcow »

Thanasis wrote:Yes but I think mcow's solution will invoke the Windows UAC message !!!
I can't specifically say no because I'm not using Windows 7, but on XP I run as an ordinary user and run my scripts all the time with no permissions failure.
wormywyrm
Posts: 73
Joined: Tue Jan 12, 2010 4:40 pm

Re: Working with Python (Google Music API)

Post by wormywyrm »

Just an update... I did get started learning Python and playing with all that, but I just have been too busy with gradschool to do a lot. This is something I plan to do someday though. Hopefully someone will come along and do it first :lol:
MM to Grooveshark Playlist Sync w/ MonkeyShark.
http://lysle.net/projects/monkeyshark.php
cobooboc
Posts: 8
Joined: Mon Sep 03, 2012 10:43 pm

Re: Working with Python (Google Music API)

Post by cobooboc »

mcow wrote:
Thanasis wrote:Yes but I think mcow's solution will invoke the Windows UAC message !!!
I can't specifically say no because I'm not using Windows 7, but on XP I run as an ordinary user and run my scripts all the time with no permissions failure.
I use Windows 7, but I also did not succeed, and this has always been a problem.
Post Reply