Example #1
0
    def get_album_art(self, song):
        try:
            last_fm = LastFM()
            link = last_fm.get_album_art_last_fm(song)
            if link:
                return link
        except Exception as e:
            logger.debug(e)
            # traceback.print_exc()
            pass
        logger.debug("Error in getting AlbumArt from Last.FM. Trying Discogs")

        try:
            discogs = Discogs()
            link = discogs.get_album_art_discogs(song)
            if link:
                return link
        except Exception as e:
            logger.debug(e)
            # traceback.print_exc()
            pass
        logger.debug("Error in getting AlbumArt from Discogs. Trying Google")

        try:
            google_search = GoogleSearch()
            link = google_search.get_album_art_google(song.artist + ' - ' +
                                                      song.title)
            if link:
                return link
        except Exception as e:
            logger.debug(e)
            traceback.print_exc()
            pass
        logger.debug("Error in getting AlbumArt from Google. Skipping..")
        return None
    def onClick(self, controlID):
        if controlID == self.C_ARTIST_LIST:
            artist = self.getControl(
                self.C_ARTIST_LIST).getSelectedItem().getProperty("artists")
            self.close()
            LFM = LastFM()
            self.GetEventsitemlist, self.GetEventsPinString = LFM.GetEvents(
                artist)
        elif controlID == 1001:

            self.close()
            log("show artist events on map")
            if xbmc.getInfoLabel("Window.IsActive()"):
                pass
            # artist = "65daysofstatic"
            # LFM = LastFM()
            # log("search for artist")
            # itemlist, self.PinString = LFM.GetEvents(artist)
            # gui.c_places_list.reset()
            # gui.GetGoogleMapURLs()
            # gui.c_places_list.addItems(items=itemlist)
            else:
                xbmc.executebuiltin(
                    "RunScript(script.maps.browser,artist=%s)" %
                    (xbmc.getInfoLabel("Window(home).Property(headliner)")))
        elif controlID == 1002:
            pass
Example #3
0
    def fix_id3(self, song):
        logger.debug(u'Writing ID3 tags to {}...'.format(song.full_title))
        try:
            audiofile = self.open_id3_tag(song.full_title)
            if audiofile.tag is None:
                audiofile.tag = eyed3.id3.Tag()
        ## Getting Lyrics from LyricsWikia
            try:
                logger.debug(u'Getting Lyrics for {} from LyricsWikia'.format(
                    song.full_title))
                lyrics = PyLyrics.getLyrics(song.artist, song.title)
                audiofile.tag.lyrics.set(u'' + lyrics)
            except ValueError as e:
                logger.warning(e.message)

            logger.debug(
                u"Writing these to tags: artist:{}, Track name: {}, Album Name: {}"
                .format(song.artist, song.title, song.album))
            artist = song.artist.strip()
            track_name = song.title.strip()
            if song.album:
                album_name = song.album.strip()
            else:
                album_name = ""
            # print (artist,track_name,album_name)

            audiofile.tag.artist = unicode(artist)
            audiofile.tag.album_artist = unicode(artist)
            audiofile.tag.title = unicode(track_name)
            audiofile.tag.album = unicode(album_name)

            last_fm = LastFM()
            genre = last_fm.get_genre_from_last_fm(song)
            if genre:
                audiofile.tag.genre = unicode(genre)
            else:
                logger.warning('Genre not found for {}'.format(
                    song.full_title))

            try:
                logger.debug("Getting AlbumArt from Discogs/LastFM/Google...")
                image_link = self.get_album_art(song)
                imagedata = requests.get(image_link).content
                audiofile.tag.images.set(0, imagedata, "image/jpeg",
                                         u"Album Art")
            except Exception as e:
                logger.error(
                    "Error in getting AlbumArt. Won't be saved to Tag")
                logger.debug(e)

            audiofile.tag.save()
            logger.info(u'ID3 Tags written and saved to {}...'.format(
                song.full_title))

        except IOError:
            logger.error(u"Can't open file. ID3 tags skipped:{}".format(
                song.full_title))
        except Exception as e:
            logger.exception("Something awful has happened")
            logger.debug(e)
Example #4
0
 def SearchDialog(self):
     modeselect = []
     modeselect.append(__language__(32024))
     modeselect.append(__language__(32004))
     modeselect.append(__language__(32023))
     modeselect.append(__language__(32033))
     modeselect.append(__language__(32019))
     dialogSelection = xbmcgui.Dialog()
     provider_index = dialogSelection.select(__language__(32026), modeselect)
     if not provider_index < 0:
         if modeselect[provider_index] == __language__(32024):
             self.SearchLocation()
             itemlist = []
         elif modeselect[provider_index] == __language__(32004):
             query = xbmcgui.Dialog().input(__language__(32022), type=xbmcgui.INPUT_ALPHANUM)
             FS = FourSquare()
             itemlist, self.PinString = FS.GetPlacesList(self.lat, self.lon, query)
         elif modeselect[provider_index] == __language__(32023):
             artist = xbmcgui.Dialog().input(__language__(32025), type=xbmcgui.INPUT_ALPHANUM)
             LFM = LastFM()
             results = LFM.GetArtistEvents(artist)
             itemlist, self.PinString = LFM.CreateVenueList(results)
         elif modeselect[provider_index] == __language__(32033):
             venue = xbmcgui.Dialog().input(__language__(32025), type=xbmcgui.INPUT_ALPHANUM)
             LFM = LastFM()
             venueid = LFM.GetVenueID(venue)
             results = LFM.GetVenueEvents(venueid)
             itemlist, self.PinString = LFM.CreateVenueList(results)
         elif modeselect[provider_index] == __language__(32019):
             self.PinString = ""
             itemlist = []
         FillListControl(self.venuelist, itemlist)
         self.street_view = False
Example #5
0
 def SelectPlacesProvider(self):
     setWindowProperty(self.window, 'index', "")
     modeselect = []
     itemlist = None
     modeselect.append(__language__(32016))  # concerts
     modeselect.append(__language__(32017))  # festivals
     modeselect.append(__language__(32027))  # geopics
     modeselect.append(__language__(32028))  # eventful
     modeselect.append(__language__(32029))  # FourSquare
     modeselect.append(__language__(32030))  # MapQuest
     modeselect.append(__language__(32031))  # Google Places
     modeselect.append(__language__(32019))  # reset
     dialogSelection = xbmcgui.Dialog()
     provider_index = dialogSelection.select(__language__(32020), modeselect)
     if not provider_index < 0:
         if modeselect[provider_index] == __language__(32031):
             GP = GooglePlaces()
             category = GP.SelectCategory()
             if category is not None:
                 self.PinString, itemlist = GP.GetGooglePlacesList(self.lat, self.lon, self.radius * 1000, category)
         elif modeselect[provider_index] == __language__(32029):
             FS = FourSquare()
             section = FS.SelectSection()
             if section is not None:
                 itemlist, self.PinString = FS.GetPlacesListExplore(self.lat, self.lon, section)
         elif modeselect[provider_index] == __language__(32016):
             LFM = LastFM()
             category = LFM.SelectCategory()
             if category is not None:
                 results = LFM.GetNearEvents(self.lat, self.lon, self.radius, category)
                 itemlist, self.PinString = LFM.CreateVenueList(results)
         elif modeselect[provider_index] == __language__(32030):
             MQ = MapQuest()
             itemlist, self.PinString = MQ.GetItemList(self.lat, self.lon, self.zoom_level)
         elif modeselect[provider_index] == __language__(32017):
             LFM = LastFM()
             category = LFM.SelectCategory()
             if category is not None:
                 results = LFM.GetNearEvents(self.lat, self.lon, self.radius, category, True)
                 itemlist, self.PinString = LFM.CreateVenueList(results)
         elif modeselect[provider_index] == __language__(32027):
             folder_path = xbmcgui.Dialog().browse(0, __language__(32021), 'pictures')
             setWindowProperty(self.window, 'imagepath', folder_path)
             itemlist, self.PinString = GetImages(folder_path)
         elif modeselect[provider_index] == __language__(32028):
             EF = Eventful()
             category = EF.SelectCategory()
             if category is not None:
                 itemlist, self.PinString = EF.GetEventfulEventList(self.lat, self.lon, "", category, self.radius)
         elif modeselect[provider_index] == __language__(32019):
             self.PinString = ""
             itemlist = []
         if itemlist is not None:
             FillListControl(self.venuelist, itemlist)
         self.street_view = False
Example #6
0
 def select_places_provider(self):
     set_window_prop(self.window, 'index', "")
     itemlist = None
     modeselect = [("concerts", ADDON_LANGUAGE(32016)),
                   ("festivals", ADDON_LANGUAGE(32017)),
                   ("geopics", ADDON_LANGUAGE(32027)),
                   ("eventful", ADDON_LANGUAGE(32028)),
                   ("foursquare", ADDON_LANGUAGE(32029)),
                   ("mapquest", ADDON_LANGUAGE(32030)),
                   ("googleplaces", ADDON_LANGUAGE(32031)),
                   ("reset", ADDON_LANGUAGE(32019))]
     listitems = [item[1] for item in modeselect]
     keys = [item[0] for item in modeselect]
     dialog = xbmcgui.Dialog()
     index = dialog.select(ADDON_LANGUAGE(32020), listitems)
     if not index < 0:
         if keys[index] == "googleplaces":
             GP = GooglePlaces()
             category = GP.select_category()
             if category is not None:
                 self.pin_string, itemlist = GP.GetGooglePlacesList(self.lat, self.lon, self.radius * 1000, category)
         elif keys[index] == "foursquare":
             FS = FourSquare()
             section = FS.SelectSection()
             if section is not None:
                 itemlist, self.pin_string = FS.GetPlacesListExplore(self.lat, self.lon, section)
         elif keys[index] == "concerts":
             LFM = LastFM()
             category = LFM.select_category()
             if category is not None:
                 results = LFM.get_near_events(self.lat, self.lon, self.radius, category)
                 itemlist, self.pin_string = LFM.create_venue_list(results)
         elif keys[index] == "mapquest":
             MQ = MapQuest()
             itemlist, self.pin_string = MQ.GetItemList(self.lat, self.lon, self.zoom_level)
         elif keys[index] == "festivals":
             LFM = LastFM()
             category = LFM.select_category()
             if category is not None:
                 results = LFM.get_near_events(self.lat, self.lon, self.radius, category, True)
                 itemlist, self.pin_string = LFM.create_venue_list(results)
         elif keys[index] == "geopics":
             folder_path = xbmcgui.Dialog().browse(0, ADDON_LANGUAGE(32021), 'pictures')
             set_window_prop(self.window, 'imagepath', folder_path)
             itemlist, self.pin_string = get_images(folder_path)
         elif keys[index] == "eventful":
             EF = Eventful()
             category = EF.select_category()
             if category is not None:
                 itemlist, self.pin_string = EF.GetEventfulEventList(self.lat, self.lon, "", category, self.radius)
         elif keys[index] == "reset":
             self.pin_string = ""
             itemlist = []
         if itemlist is not None:
             fill_list_control(self.venue_list, itemlist)
         self.street_view = False
Example #7
0
 def open_search_dialog(self):
     modeselect = [("googlemaps", ADDON_LANGUAGE(32024)),
                   ("foursquareplaces", ADDON_LANGUAGE(32004)),
                   ("lastfmconcerts", ADDON_LANGUAGE(32023)),
                   ("lastfmvenues", ADDON_LANGUAGE(32033)),
                   ("reset", ADDON_LANGUAGE(32019))]
     KEYS = [item[0] for item in modeselect]
     VALUES = [item[1] for item in modeselect]
     dialog = xbmcgui.Dialog()
     index = dialog.select(ADDON_LANGUAGE(32026), VALUES)
     if index < 0:
         return None
     if KEYS[index] == "googlemaps":
         self.search_location()
         itemlist = []
     elif KEYS[index] == "foursquareplaces":
         query = xbmcgui.Dialog().input(ADDON_LANGUAGE(32022), type=xbmcgui.INPUT_ALPHANUM)
         FS = FourSquare()
         itemlist, self.pin_string = FS.GetPlacesList(self.lat, self.lon, query)
     elif KEYS[index] == "lastfmconcerts":
         artist = xbmcgui.Dialog().input(ADDON_LANGUAGE(32025), type=xbmcgui.INPUT_ALPHANUM)
         LFM = LastFM()
         results = LFM.get_artist_events(artist)
         itemlist, self.pin_string = LFM.create_venue_list(results)
     elif KEYS[index] == "lastfmvenues":
         venue = xbmcgui.Dialog().input(ADDON_LANGUAGE(32025), type=xbmcgui.INPUT_ALPHANUM)
         LFM = LastFM()
         venueid = LFM.get_venue_id(venue)
         results = LFM.get_venue_events(venueid)
         itemlist, self.pin_string = LFM.create_venue_list(results)
     elif KEYS[index] == "reset":
         self.pin_string = ""
         itemlist = []
     fill_list_control(self.venue_list, itemlist)
     self.street_view = False
Example #8
0
 def __init__(self, skin_file, ADDON_PATH, *args, **kwargs):
     self.itemlist = []
     self.location = kwargs.get("location", "")
     self.type = kwargs.get("type", "roadmap")
     self.strlat = kwargs.get("lat", "")
     self.strlon = kwargs.get("lon", "")
     self.zoom_level = kwargs.get("zoom_level", 10)
     self.aspect = kwargs.get("aspect", "640x400")
     self.init_vars()
     for arg in sys.argv:
         param = arg.lower()
         log("param = " + param)
         if param.startswith('folder='):
             folder = param[7:]
             self.itemlist, self.pin_string = self.get_images(folder)
         elif param.startswith('artist='):
             artist = param[7:]
             LFM = LastFM()
             results = LFM.get_artist_events(artist)
             self.itemlist, self.pin_string = LFM.create_venue_list(results)
         elif param.startswith('list='):
             listtype = param[5:]
             self.zoom_level = 14
             if listtype == "nearfestivals":
                 LFM = LastFM()
                 results = LFM.get_near_events(self.lat, self.lon, self.radius, "", True)
                 self.itemlist, self.pin_string = LFM.create_venue_list(results)
             elif listtype == "nearconcerts":
                 LFM = LastFM()
                 results = LFM.get_near_events(self.lat, self.lon, self.radius)
                 self.itemlist, self.pin_string = LFM.create_venue_list(results)
         elif param.startswith('direction='):
             self.direction = param[10:]
         elif param.startswith('prefix='):
             self.prefix = param[7:]
             if not self.prefix.endswith('.') and self.prefix != "":
                 self.prefix = self.prefix + '.'
         # get lat / lon values
     if self.location == "geocode":
         self.lat, self.lon = parse_geotags(self.strlat, self.strlon)
     elif (self.location == "") and (self.strlat == ""):  # both empty
         self.lat, self.lon = get_location_coords()
         self.zoom_level = 2
     elif (not self.location == "") and (self.strlat == ""):  # latlon empty
         self.lat, self.lon = self.get_geocodes(False, self.location)
     else:
         self.lat = float(self.strlat)
         self.lon = float(self.strlon)
Example #9
0
    def __init__(self, session, streamplayer, args=0):
        self.skin = LastFMScreenMain.skin
        Screen.__init__(self, session)
        HelpableScreen.__init__(self)
        LastFM.__init__(self)
        self.session = session
        self.streamplayer = streamplayer  #StreamPlayer(session)
        self.streamplayer.onStateChanged.append(
            self.onStreamplayerStateChanged)
        self.imageconverter = ImageConverter(116, 116, self.setCoverArt)
        Screen.__init__(self, session)

        self.tabs = [(_("Personal Stations"), self.loadPersonalStations),
                     (_("Global Tags"), self.loadGlobalTags),
                     (_("Top Tracks"), self.loadTopTracks),
                     (_("Recent Tracks"), self.loadRecentTracks),
                     (_("Loved Tracks"), self.loadLovedTracks),
                     (_("Banned Tracks"), self.loadBannedTracks),
                     (_("Friends"), self.loadFriends),
                     (_("Neighbours"), self.loadNeighbours)]
        tablist = []
        for tab in self.tabs:
            tablist.append((tab[0], tab))
        self.tablist = MenuList(tablist)
        self.tablist.onSelectionChanged.append(self.action_TabChanged)

        self["artist"] = Label(_("Artist") + ":")
        self["duration"] = Label("-00:00")
        self["album"] = Label(_("Album") + ":")
        self["track"] = Label(_("Track") + ":")

        self["info_artist"] = Label("N/A")
        self["info_album"] = Label("N/A")
        self["info_track"] = Label("N/A")
        self["info_cover"] = Pixmap()

        self["tablist"] = self.tablist
        self["streamlist"] = MenuList([])

        self["button_red"] = Label(_("Play"))
        self["button_green"] = Label(_("Skip"))
        self["button_yellow"] = Label(_("Love"))
        self["button_blue"] = Label(_("Ban"))
        self["infolabel"] = Label("")

        self["actions"] = ActionMap(
            [
                "InfobarChannelSelection", "WizardActions", "DirectionActions",
                "MenuActions", "ShortcutActions", "GlobalActions",
                "HelpActions", "NumberActions"
            ], {
                "ok": self.action_ok,
                "back": self.action_exit,
                "red": self.action_startstop,
                "green": self.skipTrack,
                "yellow": self.love,
                "blue": self.banTrack,
                "historyNext": self.action_nextTab,
                "historyBack": self.action_prevTab,
                "menu": self.action_menu,
            }, -1)

        self.helpList.append((self["actions"], "WizardActions",
                              [("ok", _("Switch to selected Station"))]))
        self.helpList.append((self["actions"], "InfobarChannelSelection",
                              [("historyNext", _("Select next Tab"))]))
        self.helpList.append((self["actions"], "InfobarChannelSelection",
                              [("historyBack", _("Select prev Tab"))]))
        self.helpList.append((self["actions"], "InfobarChannelSelection",
                              [("switchChannelDown", _("Next Selection"))]))
        self.helpList.append((self["actions"], "InfobarChannelSelection",
                              [("switchChannelUp", _("Previous Selection"))]))
        self.helpList.append((self["actions"], "InfobarChannelSelection",
                              [("zapDown", _("Page forward Selections"))]))
        self.helpList.append((self["actions"], "InfobarChannelSelection",
                              [("zapUp", _("Page backward Selections"))]))
        self.helpList.append((self["actions"], "ShortcutActions",
                              [("red", _("Start/stop streaming"))]))
        self.helpList.append(
            (self["actions"], "ShortcutActions", [("green",
                                                   _("Skip current Track"))]))
        self.helpList.append(
            (self["actions"], "ShortcutActions", [("yellow",
                                                   _("Mark Track as loved"))]))
        self.helpList.append((self["actions"], "ShortcutActions",
                              [("blue", _("Ban Track, never play"))]))
        self.helpList.append((self["actions"], "MenuActions",
                              [("menu", _("Open") + " " + _("Setup"))]))
        self.helpList.append((self["actions"], "WizardActions", [
            ("back", _("Quit") + " " + config.plugins.LastFM.name.value)
        ]))

        self.onLayoutFinish.append(self.initLastFM)
        self.onLayoutFinish.append(self.tabchangedtimerFired)
        self.onLayoutFinish.append(self.setCoverArt)

        self.guiupdatetimer = eTimer()
        self.guiupdatetimer.timeout.get().append(self.guiupdatetimerFired)
        self.guiupdatetimer.start(
            config.plugins.LastFM.metadatarefreshinterval.value * 1000)

        self.tabchangetimer = eTimer()
        self.tabchangetimer.timeout.get().append(self.tabchangedtimerFired)

        self.infolabelcleartimer = eTimer()
        self.infolabelcleartimer.timeout.get().append(self.clearInfoLabel)

        self.screensavertimer = eTimer()
        self.screensavertimer.timeout.get().append(self.startScreensaver)
        self.onShown.append(self.startScreensaverTimer)
Example #10
0
    def __init__(self, session, streamplayer, args=0):
        self.skin = LastFMScreenMain.skin
        Screen.__init__(self, session)
        HelpableScreen.__init__(self)
        LastFM.__init__(self)
        self.session = session
        self.streamplayer = streamplayer  # StreamPlayer(session)
        self.streamplayer.onStateChanged.append(self.onStreamplayerStateChanged)
        self.imageconverter = ImageConverter(116, 116, self.setCoverArt)
        Screen.__init__(self, session)

        self.tabs = [
            (_("Personal Stations"), self.loadPersonalStations),
            (_("Global Tags"), self.loadGlobalTags),
            (_("Top Tracks"), self.loadTopTracks),
            (_("Recent Tracks"), self.loadRecentTracks),
            (_("Loved Tracks"), self.loadLovedTracks),
            (_("Banned Tracks"), self.loadBannedTracks),
            (_("Friends"), self.loadFriends),
            (_("Neighbours"), self.loadNeighbours)
        ]
        tablist = []
        for tab in self.tabs:
            tablist.append((tab[0], tab))
        self.tablist = MenuList(tablist)
        self.tablist.onSelectionChanged.append(self.action_TabChanged)

        self["artist"] = Label(_("Artist") + ":")
        self["duration"] = Label("-00:00")
        self["album"] = Label(_("Album") + ":")
        self["track"] = Label(_("Track") + ":")

        self["info_artist"] = Label("N/A")
        self["info_album"] = Label("N/A")
        self["info_track"] = Label("N/A")
        self["info_cover"] = Pixmap()

        self["tablist"] = self.tablist
        self["streamlist"] = MenuList([])

        self["key_red"] = Label(_("Play"))
        self["key_green"] = Label(_("Skip"))
        self["key_yellow"] = Label(_("Love"))
        self["key_blue"] = Label(_("Ban"))
        self["infolabel"] = Label("")

        self["actions"] = HelpableActionMap(self, ["InfobarChannelSelection", "WizardActions", "ShortcutActions", "MenuActions"], {
            "ok": (self.action_ok, _("Switch to selected station")),
            "back": (self.action_exit, _("Quit") + " " + config.plugins.LastFM.name.value),
            "red": (self.action_startstop, _("Start/stop streaming")),
            "green": (self.skipTrack, _("Skip current track")),
            "yellow": (self.love, _("Mark track as loved")),
            "blue": (self.banTrack, _("Ban track, never play")),
            "historyNext": (self.action_nextTab, _("Select next tab")),
            "historyBack": (self.action_prevTab, _("Select prev tab")),

            "menu": (self.action_menu, _("Open setup menu")),
        }, prio=-1, description=config.plugins.LastFM.name.value)

        # Unimplemented actions that were given help entries.
        # Perhaps there was an intention to implement them at some stage.

        # self.helpList.append((self["actions"], "InfobarChannelSelection", [("switchChannelDown", _("Next selection"))]))
        # self.helpList.append((self["actions"], "InfobarChannelSelection", [("switchChannelUp", _("Previous selection"))]))
        # self.helpList.append((self["actions"], "InfobarChannelSelection", [("zapDown", _("Page forward selections"))]))
        # self.helpList.append((self["actions"], "InfobarChannelSelection", [("zapUp", _("Page backward selections"))]))

        self.onLayoutFinish.append(self.initLastFM)
        self.onLayoutFinish.append(self.tabchangedtimerFired)
        self.onLayoutFinish.append(self.setCoverArt)

        self.guiupdatetimer = eTimer()
        self.guiupdatetimer.timeout.get().append(self.guiupdatetimerFired)
        self.guiupdatetimer.start(config.plugins.LastFM.metadatarefreshinterval.value * 1000)

        self.tabchangetimer = eTimer()
        self.tabchangetimer.timeout.get().append(self.tabchangedtimerFired)

        self.infolabelcleartimer = eTimer()
        self.infolabelcleartimer.timeout.get().append(self.clearInfoLabel)

        self.screensavertimer = eTimer()
        self.screensavertimer.timeout.get().append(self.startScreensaver)
        self.onShown.append(self.startScreensaverTimer)
 def onInit(self):
     LFM = LastFM()
     self.itemlist, PinString = LFM.GetVenueEvents(self.venueid)
     self.prop_list = simplejson.loads(
         self.itemlist[0].getProperty("item_info"))
     self.setControls()
Example #12
0
 def onInit(self, startGUI=True):
     log('onInit')
     itemlist = []
     self.init_vars()
     log("WindowID:" + str(xbmcgui.getCurrentWindowId()))
     self.window = xbmcgui.Window(xbmcgui.getCurrentWindowId())
     log("window = " + str(self.window))
     setWindowProperty(self.window, 'NavMode', '')
     setWindowProperty(self.window, 'streetview', '')
     if __addon__.getSetting("VenueLayout") == "1":
         setWindowProperty(self.window, 'ListLayout', '1')
     else:
         setWindowProperty(self.window, 'ListLayout', '0')
     for arg in sys.argv:
         param = arg.lower()
         log("param = " + param)
         if param.startswith('location='):
             self.location = param[9:]
         elif param.startswith('lat='):
             self.strlat = param[4:]
         elif param.startswith('lon='):
             self.strlon = param[4:]
         elif param.startswith('type='):
             self.type = param[5:]
         elif param.startswith('zoom='):
             self.zoom_level = param[5:]
         elif param.startswith('aspect='):
             self.aspect = param[7:]
         elif param.startswith('folder='):
             folder = param[7:]
             itemlist, self.PinString = self.GetImages(folder)
         elif param.startswith('artist='):
             artist = param[7:]
             LFM = LastFM()
             results = LFM.GetArtistEvents(artist)
             itemlist, self.PinString = LFM.CreateVenueList(results)
         elif param.startswith('list='):
             listtype = param[5:]
             self.zoom_level = 14
             if listtype == "nearfestivals":
                 LFM = LastFM()
                 results = LFM.GetNearEvents(self.lat, self.lon, self.radius, "", True)
                 itemlist, self.PinString = LFM.CreateVenueList(results)
             elif listtype == "nearconcerts":
                 LFM = LastFM()
                 results = LFM.GetNearEvents(self.lat, self.lon, self.radius)
                 itemlist, self.PinString = LFM.CreateVenueList(results)
         elif param.startswith('direction='):
             self.direction = param[10:]
         elif param.startswith('prefix='):
             self.prefix = param[7:]
             if not self.prefix.endswith('.') and self.prefix != "":
                 self.prefix = self.prefix + '.'
         # get lat / lon values
     if self.location == "geocode":
         self.lat, self.lon = ParseGeoTags(self.strlat, self.strlon)
     elif (self.location == "") and (self.strlat == ""):  # both empty
         self.lat, self.lon = GetLocationCoordinates()
         self.zoom_level = 2
     elif (not self.location == "") and (self.strlat == ""):  # latlon empty
         self.lat, self.lon = self.GetGeoCodes(False, self.location)
     else:
         self.lat = float(self.strlat)
         self.lon = float(self.strlon)
     self.GetGoogleMapURLs()
     if startGUI:
         self.venuelist = self.getControl(self.CONTROL_PLACES_LIST)
         self.GetGoogleMapURLs()
         FillListControl(self.venuelist, itemlist)
         self.window.setProperty("map_image", self.GoogleMapURL)
         self.window.setProperty("streetview_image", self.GoogleStreetViewURL)
         settings = xbmcaddon.Addon(id='script.maps.browser')
         if not settings.getSetting('firststart') == "true":
             settings.setSetting(id='firststart', value='true')
             dialog = xbmcgui.Dialog()
             dialog.ok(__language__(32001), __language__(32002), __language__(32003))
     log('onInit finished')
Example #13
0
    def __init__(self, session,streamplayer, args = 0):
        self.skin = LastFMScreenMain.skin
        Screen.__init__(self, session)
        HelpableScreen.__init__(self)
        LastFM.__init__(self)
        self.session = session
        self.streamplayer = streamplayer#StreamPlayer(session)
        self.streamplayer.onStateChanged.append(self.onStreamplayerStateChanged)
        self.imageconverter = ImageConverter(116,116,self.setCoverArt)
        Screen.__init__(self, session)
        
        self.tabs=[(_("Personal Stations"),self.loadPersonalStations)
                   ,(_("Global Tags"),self.loadGlobalTags)
                   ,(_("Top Tracks"),self.loadTopTracks)
                   ,(_("Recent Tracks"),self.loadRecentTracks)
                   ,(_("Loved Tracks"),self.loadLovedTracks)
                   ,(_("Banned Tracks"),self.loadBannedTracks)
                   ,(_("Friends"),self.loadFriends)
                   ,(_("Neighbours"),self.loadNeighbours)
                   ]
        tablist =[]
        for tab in self.tabs:
            tablist.append((tab[0],tab))
        self.tablist = MenuList(tablist)
        self.tablist.onSelectionChanged.append(self.action_TabChanged)
        
        self["artist"] = Label(_("Artist")+":")
        self["duration"] = Label("-00:00")
        self["album"] = Label(_("Album")+":")
        self["track"] = Label(_("Track")+":")
        
        self["info_artist"] = Label("N/A")
        self["info_album"] = Label("N/A")
        self["info_track"] = Label("N/A")
        self["info_cover"] = Pixmap()
        
        self["tablist"] = self.tablist
        self["streamlist"] = MenuList([])
        
        self["button_red"] = Label(_("Play"))
        self["button_green"] = Label(_("Skip"))
        self["button_yellow"] = Label(_("Love"))
        self["button_blue"] = Label(_("Ban"))
        self["infolabel"] = Label("")
        
        self["actions"] = ActionMap(["InfobarChannelSelection","WizardActions", "DirectionActions","MenuActions","ShortcutActions","GlobalActions","HelpActions","NumberActions"], 
            {
             "ok": self.action_ok,
             "back": self.action_exit,
             "red": self.action_startstop,
             "green": self.skipTrack,
             "yellow": self.love,
             "blue": self.banTrack ,
             "historyNext": self.action_nextTab,
             "historyBack": self.action_prevTab,
             
             "menu": self.action_menu,
             }, -1)
        
        self.helpList.append((self["actions"], "WizardActions", [("ok", _("Switch to selected Station"))]))
        self.helpList.append((self["actions"], "InfobarChannelSelection", [("historyNext", _("Select next Tab"))]))
        self.helpList.append((self["actions"], "InfobarChannelSelection", [("historyBack", _("Select prev Tab"))]))
        self.helpList.append((self["actions"], "InfobarChannelSelection", [("switchChannelDown", _("Next Selection"))]))
        self.helpList.append((self["actions"], "InfobarChannelSelection", [("switchChannelUp", _("Previous Selection"))]))     
        self.helpList.append((self["actions"], "InfobarChannelSelection", [("zapDown", _("Page forward Selections"))]))
        self.helpList.append((self["actions"], "InfobarChannelSelection", [("zapUp", _("Page backward Selections"))]))
        self.helpList.append((self["actions"], "ShortcutActions", [("red", _("Start/stop streaming"))]))
        self.helpList.append((self["actions"], "ShortcutActions", [("green", _("Skip current Track"))]))
        self.helpList.append((self["actions"], "ShortcutActions", [("yellow", _("Mark Track as loved"))]))
        self.helpList.append((self["actions"], "ShortcutActions", [("blue", _("Ban Track, never play"))]))		
        self.helpList.append((self["actions"], "MenuActions", [("menu", _("Open") + " " + _("Setup"))]))		
        self.helpList.append((self["actions"], "WizardActions", [("back", _("Quit") + " " + config.plugins.LastFM.name.value)]))

        self.onLayoutFinish.append(self.initLastFM)
        self.onLayoutFinish.append(self.tabchangedtimerFired)
        self.onLayoutFinish.append(self.setCoverArt)
        
        self.guiupdatetimer = eTimer()
        self.guiupdatetimer_conn = self.guiupdatetimer.timeout.connect(self.guiupdatetimerFired)
        self.guiupdatetimer.start(config.plugins.LastFM.metadatarefreshinterval.value*1000)
        
        self.tabchangetimer = eTimer()
        self.tabchangetimer_conn = self.tabchangetimer.timeout.connect(self.tabchangedtimerFired)
        
        self.infolabelcleartimer = eTimer()
        self.infolabelcleartimer_conn = self.infolabelcleartimer.timeout.connect(self.clearInfoLabel)

        self.screensavertimer = eTimer()
        self.screensavertimer_conn = self.screensavertimer.timeout.connect(self.startScreensaver)
        self.onShown.append(self.startScreensaverTimer)