2016-06-28 22:32:32 -05:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
import widgetUtils
|
|
|
|
from wxUI.dialogs import selector as gui
|
|
|
|
|
2016-08-14 07:46:41 -05:00
|
|
|
class album(object):
|
2016-06-28 22:32:32 -05:00
|
|
|
|
2016-08-14 07:46:41 -05:00
|
|
|
def __init__(self, title, session, album_type="audio_albums"):
|
|
|
|
super(album, self).__init__()
|
2016-06-28 22:32:32 -05:00
|
|
|
self.item = None
|
|
|
|
self.session = session
|
2016-08-14 07:46:41 -05:00
|
|
|
if not hasattr(self.session, album_type):
|
|
|
|
return
|
|
|
|
self.albums = getattr(self.session, album_type)
|
2016-06-28 22:32:32 -05:00
|
|
|
self.dialog = gui.selectAlbum(title=title, albums=self.get_albums_as_string())
|
|
|
|
response = self.dialog.get_response()
|
|
|
|
if response == widgetUtils.OK:
|
|
|
|
self.item = self.search_item(self.dialog.get_string())
|
|
|
|
|
|
|
|
def get_albums_as_string(self):
|
2016-08-14 07:46:41 -05:00
|
|
|
return [i["title"] for i in self.albums]
|
2016-06-28 22:32:32 -05:00
|
|
|
|
|
|
|
def search_item(self, item):
|
2016-08-14 07:46:41 -05:00
|
|
|
for i in self.albums:
|
2016-06-28 22:32:32 -05:00
|
|
|
if i["title"] == item:
|
|
|
|
return i["id"]
|
|
|
|
return None
|
2016-08-14 07:46:41 -05:00
|
|
|
|