AlbumObject

I’m having a devil of a time using the AlbumObject class. Is this one considered working? I keep getting the error “AttributeException: If no URL is provided, the key and rating_key attributes must be set.”



I’ve tried specifying a dummy url value, as well as using both key and rating_key but it doesn’t seem to care.



I noticed the Spotify plugin just uses an ObjectContainer for pretty much everyting. Is that what I should use instead?

The Last Music Archive (LMA.bundle) uses Album Objects. The associated URL Service is listed as com.plexapp.plugins.internetarchive in the Services.bundle. It’s a fairly complicated example but it works well.


Interesting. I didn't know much about URL Services so I checked out the documentation and... well I'm still a little fuzzy. It looks like they're useful if you start with a URL, the service will parse and grab the data for you. In my case I'm not starting with a URL, but instead a list of media from a 3rd party Python library. I found that I could just put url = "http://google.com" and it would work just fine for me, but I don't know if that's going to cause problems. I've been able to use the key + rating_key combo for the ArtistObject, but that same method doesn't appear to work for AlbumObject, despite the error.

The key + rating_key combo should work. It’s my understanding that PMS expects the key attribute to point to a Callback which will return more info about the object. For an AlbumObject, I would think it should be something like:



<br />
def ListOfAlbums():<br />
	oc = ObjectContainer()<br />
<br />
	oc.add(<br />
		AlbumObject(<br />
			key = Callback(AlbumTracks, album_identifier, album_title, album_artist, album_thumb, album_art),<br />
			rating_key = album_identifier,<br />
			title = album_title,<br />
			artist = album_artist,<br />
			thumb = album_thumb,<br />
			art  = album_art<br />
		)<br />
	)<br />
<br />
return oc<br />
<br />
def AlbumTracks(album_identifier, album_title, album_artist, album_thumb, album_art):<br />
	oc = ObjectContainer()<br />
	<br />
	tracks = album_tracks #however you determine what tracks are part of the given album<br />
	for track in tracks:<br />
		oc.add(<br />
			TrackObject(<br />
				... #fill in the details<br />
			)<br />
		)<br />
<br />
	return oc<br />





Adding a dummy url isn't unreasonable if you're actually using it to manipulate data but I would advise against making it point to any real website then. If you choose to use urls to manipulate data, you will of course need to include the necessary URL service in the plugin bundle so that the url is matched and handled properly. I might use an url like my-url://music-plugin/artist=/album=/track= which would allow you to pass whatever information you want/need back and forth. That is, of course, just one way of handling it.

Ah, so I think my problem was one of the keys I was using for key or rating_key was empty. I did some cleaning and filtering on my data to eliminate that stuff and was able to use the AlbumObject with key+rating_key combo.



Just so I’m clear on them, URL services aren’t necessary, correct? They may be handy, especially if your content retrieve all via URLs, but if I can get away with not using them is it OK? Just want to make sure I’m not breaking any cardinal rules :slight_smile:



Thanks for your help, I hope to have my plugin released for testing here soon.

URL Services are not required. They tend to get pushed because the general focus for channels is web content and URL services give the added bonus of PlexIt queue support as well as the benefit of not having to mess with keys and rating_keys. It sounds like it doesn’t really make sense to use an URL service for your project and that’s fine. There are no real Cardinal Rules of channel development. You can do pretty much whatever you want as long as it works. However, if you want your plugin to be accessible in the official Channel Directory (rather than just for personal use or available unofficially) there are a few guidelines but few hard and fast rules.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.