Example #1
0
def get_albums_list_from_artist(artist):
    msg = GET_ALBUMS_FROM_ARTIST % artist
    res = json.loads(send_json(msg))
    albums_list = []
    if res.has_key('result'):
      for album in res['result']['albums']:
          el = album['albumid']
          artists = ''
          for item in album['artist']: 
            artists += ' ' + app_utils.upperUTF8(unicodeToUTF8(item))
          if el not in albums_list and app_utils.upperUTF8(artist) in artists:
              print ' '.join(album['artist']), album['title'], album['year'], album['albumid']
              #print "add"
              albums_list.append(el)


      return albums_list
    elif res.has_key('error'):
        print("no albums found: %s" % res['error'] )
        return None
Example #2
0
def get_albums_list_from_artist(artist):
    msg = GET_ALBUMS_FROM_ARTIST % artist
    res = json.loads(send_json(msg))
    albums_list = []
    if res.has_key('result'):
        for album in res['result']['albums']:
            el = album['albumid']
            artists = ''
            for item in album['artist']:
                artists += ' ' + app_utils.upperUTF8(unicodeToUTF8(item))
            if el not in albums_list and app_utils.upperUTF8(
                    artist) in artists:
                print ' '.join(
                    album['artist']
                ), album['title'], album['year'], album['albumid']
                #print "add"
                albums_list.append(el)

        return albums_list
    elif res.has_key('error'):
        print("no albums found: %s" % res['error'])
        return None
Example #3
0
def handle(text, mic, profile, logger, modules):
    """
        Responds to user-input, typically speech text, with a summary of
        the relevant weather for the requested date (typically, weather
        information will not be available for days beyond tomorrow).

        Arguments:
        text -- user-input, typically transcribed speech
        mic -- used to interact with the user (for both input and output)
        profile -- contains information related to the user (e.g., phone number)
        typical command:
        puść|odtwarzaj|graj|zagraj
            [mi|teraz|proszę|wszystkie płyty|płytę]
              zespołu|zespół|artystę|wykonawcę|płyty %ARTIST% $
                | album|płytę %ALBUM%
              muzykę dla dzieci
              losowo muzykę
              radio %RADIO%
              filmiki dla dzieci
              film %MOVIE%
              plik %FILE%
              serial %SHOW%
              zdjęcia|pokaz zdjęć losowo|%FOLDER%

    """
    global SERWERS
    SERWERS['DEFAULT'] = SERWERS[profile['xbmc_server'].upper()]
    ACTION_PLAY = ["PUŚĆ", "ODTWARZAJ", "GRAJ", "ZAGRAJ"]
    ACTION_PAUSE = ["WSTRZYMAJ", "ZATRZYMAJ"]
    CONTENT_ARTIST = ["ZESPÓŁ", "ARTYSTĘ", "ARTYSTKĘ", "WYKONAWCĘ", "PŁYTY"]
    CONTENT_SONG = ["UTWÓR", "PIOSENKĘ", "PIOSENKE", "KAWAŁEK"]
    CONTENT_RADIO = ["RADIO"]
    CONTENT_ALBUM = ["ALBUM", "PŁYTĘ"]
    CONTENT_MOVIE = ["FILM"]
    CONTENT_SHOW = ["SERIAL", "ODCINEK"]

    init_play = False
    init_pause = False
    #phrases = text.decode('utf-8').upper().encode("utf-8").split(" ")
    phrases = app_utils.upperUTF8(text).split(" ")

    if app_utils.upperUTF8(text) == 'CO JEST GRANE':
        msg = get_currently_playing()
        if msg:
            mic.say(msg)
        return

    if app_utils.upperUTF8(text) == 'TRYB IMPREZY':
        msg = start_party_mode('music')
        if msg:
            mic.say('Napełniam szklaneczki')
        return

    #print " ".join(phrases)
    for a in ACTION_PLAY:
        if a in phrases:
            init_play = True
            break
    for a in ACTION_PAUSE:
        if a in phrases:
            init_pause = True
            break

    if (init_pause and init_play) or (not init_pause and not init_play):
        print("play %d pause %d" % (init_play, init_pause))
        mic.say(
            "Wybacz, ale nie rozumiem polecenia, multimedialnego wstrzymaj lub uruchom"
        )
        return

    content_type = None

    if init_pause or (init_play and len(phrases) == 1):
        pausePlayer()
        return

    shuffled = False
    if 'LOSOWO' in phrases:
        shuffled = True

    for c in CONTENT_ARTIST:
        if c in phrases:
            content_type = "ARTIST"
            index = phrases.index(c) + 1
            artist = " ".join(phrases[index:])
            break
    for c in CONTENT_ALBUM:
        if c in phrases:
            content_type = "ALBUM"
            index = phrases.index(c) + 1
            album = " ".join(phrases[index:])
            break
    for c in CONTENT_SONG:
        if c in phrases:
            content_type = "SONG"
            index = phrases.index(c) + 1
            song = " ".join(phrases[index:])
            break
    for c in CONTENT_RADIO:
        if c in phrases:
            content_type = "RADIO"
            index = phrases.index(c) + 1
            radio = " ".join(phrases[index:])
            break
    for c in CONTENT_ALBUM:
        if c in phrases:
            content_type = "ALBUM"
            index = phrases.index(c) + 1
            album = " ".join(phrases[index:])
            break
    for c in CONTENT_MOVIE:
        if c in phrases:
            content_type = "MOVIE"
            index = phrases.index(c) + 1
            movie = " ".join(phrases[index:])
            #print movie
            break
    for c in CONTENT_SHOW:
        if c in phrases:
            content_type = "SHOW"
            index = phrases.index(c) + 1
            show = " ".join(phrases[index:])
            break

    if not content_type:
        mic.say("Wybacz, ale nie rozumiem polecenia multimedialnego")
        return
    if content_type == "RADIO":
        res = play_radio(radio, mic)
        if not res:
            mic.say(
                "Wybacz, ale nie znaleziono stacji radiowej o nazwie|~ %s" %
                radio)
    if content_type == "ARTIST":
        res = play_artist(artist, shuffled)
        if not res:
            mic.say("Wybacz, ale nie znaleziono artysty o nazwie|~ %s" %
                    artist)
    if content_type == "ALBUM":
        res = play_album(album, shuffled)
        if not res:
            mic.say("Wybacz, ale nie znaleziono albumu o nazwie|~ %s" % album)
    if content_type == "SONG":
        res = play_songs(song, shuffled)
        if not res:
            mic.say("Wybacz, ale nie znaleziono utworu o nazwie|~ %s" % song)
    if content_type == "MOVIE":
        res = play_movies(movie, shuffled)
        if not res:
            mic.say("Wybacz, ale nie znaleziono filmu zatytułowanego|~ %s" %
                    movie)
    if content_type == "SHOW":
        res = play_show(show, shuffled)
        if not res:
            mic.say("Wybacz, ale nie znaleziono serialu o nazwie|~ %s" % show)
Example #4
0
def handle(text, mic, profile, logger, modules):
    """
        Responds to user-input, typically speech text, with a summary of
        the relevant weather for the requested date (typically, weather
        information will not be available for days beyond tomorrow).

        Arguments:
        text -- user-input, typically transcribed speech
        mic -- used to interact with the user (for both input and output)
        profile -- contains information related to the user (e.g., phone number)
        typical command:
        puść|odtwarzaj|graj|zagraj
            [mi|teraz|proszę|wszystkie płyty|płytę]
              zespołu|zespół|artystę|wykonawcę|płyty %ARTIST% $
                | album|płytę %ALBUM%
              muzykę dla dzieci
              losowo muzykę
              radio %RADIO%
              filmiki dla dzieci
              film %MOVIE%
              plik %FILE%
              serial %SHOW%
              zdjęcia|pokaz zdjęć losowo|%FOLDER%

    """
    global SERWERS
    SERWERS['DEFAULT'] = SERWERS[profile['xbmc_server'].upper()]
    ACTION_PLAY = ["PUŚĆ", "ODTWARZAJ", "GRAJ", "ZAGRAJ"]
    ACTION_PAUSE = ["WSTRZYMAJ", "ZATRZYMAJ"]
    CONTENT_ARTIST = ["ZESPÓŁ", "ARTYSTĘ", "ARTYSTKĘ", "WYKONAWCĘ", "PŁYTY"]
    CONTENT_SONG   = ["UTWÓR", "PIOSENKĘ", "PIOSENKE", "KAWAŁEK"]
    CONTENT_RADIO  = ["RADIO"]
    CONTENT_ALBUM  = ["ALBUM", "PŁYTĘ"]
    CONTENT_MOVIE  = ["FILM"]
    CONTENT_SHOW   = ["SERIAL", "ODCINEK"]

    init_play = False
    init_pause = False
    #phrases = text.decode('utf-8').upper().encode("utf-8").split(" ")
    phrases = app_utils.upperUTF8(text).split(" ")


    if app_utils.upperUTF8(text) == 'CO JEST GRANE':
      msg = get_currently_playing()
      if msg:
        mic.say(msg)
      return

    if app_utils.upperUTF8(text) == 'TRYB IMPREZY':
      msg = start_party_mode('music')
      if msg:
        mic.say('Napełniam szklaneczki')
      return

    #print " ".join(phrases)
    for a in ACTION_PLAY:
        if a in phrases:
            init_play = True
            break
    for a in ACTION_PAUSE:
        if a in phrases:
            init_pause = True
            break

    if (init_pause and init_play) or (not init_pause and not init_play):
        print("play %d pause %d" % (init_play, init_pause))
        mic.say("Wybacz, ale nie rozumiem polecenia, multimedialnego wstrzymaj lub uruchom")
        return
    
    content_type = None
    
    if init_pause or (init_play and len(phrases) == 1):
      pausePlayer()
      return
    
    shuffled = False
    if 'LOSOWO' in phrases:
      shuffled = True
    
    for c in CONTENT_ARTIST:
        if c in phrases:
            content_type = "ARTIST"
            index = phrases.index(c) + 1
            artist = " ".join(phrases[index:])
            break
    for c in CONTENT_ALBUM:
        if c in phrases:
            content_type = "ALBUM"
            index = phrases.index(c) + 1
            album = " ".join(phrases[index:])
            break
    for c in CONTENT_SONG:
        if c in phrases:
            content_type = "SONG"
            index = phrases.index(c) + 1
            song = " ".join(phrases[index:])
            break
    for c in CONTENT_RADIO:
        if c in phrases:
            content_type = "RADIO"
            index = phrases.index(c) + 1
            radio = " ".join(phrases[index:])
            break
    for c in CONTENT_ALBUM:
        if c in phrases:
            content_type = "ALBUM"
            index = phrases.index(c) + 1
            album = " ".join(phrases[index:])
            break
    for c in CONTENT_MOVIE:
        if c in phrases:
            content_type = "MOVIE"
            index = phrases.index(c) + 1
            movie = " ".join(phrases[index:])
            #print movie
            break
    for c in CONTENT_SHOW:
        if c in phrases:
            content_type = "SHOW"
            index = phrases.index(c) + 1
            show = " ".join(phrases[index:])
            break

    if not content_type:
        mic.say("Wybacz, ale nie rozumiem polecenia multimedialnego")
        return
    if content_type == "RADIO":
        res = play_radio(radio, mic)
        if not res:
            mic.say("Wybacz, ale nie znaleziono stacji radiowej o nazwie|~ %s" % radio)
    if content_type == "ARTIST":
        res = play_artist(artist, shuffled)
        if not res:
            mic.say("Wybacz, ale nie znaleziono artysty o nazwie|~ %s" % artist)
    if content_type == "ALBUM":
        res = play_album(album, shuffled)
        if not res:
            mic.say("Wybacz, ale nie znaleziono albumu o nazwie|~ %s" % album)
    if content_type == "SONG":
        res = play_songs(song, shuffled)
        if not res:
            mic.say("Wybacz, ale nie znaleziono utworu o nazwie|~ %s" % song)
    if content_type == "MOVIE":
        res = play_movies(movie, shuffled)
        if not res:
            mic.say("Wybacz, ale nie znaleziono filmu zatytułowanego|~ %s" % movie)
    if content_type == "SHOW":
        res = play_show(show, shuffled)
        if not res:
            mic.say("Wybacz, ale nie znaleziono serialu o nazwie|~ %s" % show)