Exemplo n.º 1
0
def test_elisa_program_fail():
    with HTTMock(elisaviihde_api_mock, elisaviihde_sso_mock):
        elisa = elisaviihde.elisaviihde(False)
        elisa.login("foo", "bar")
        program = elisa.getprogram(1239)
    assert program["serviceName"] == "dummy-channel-name"
    assert program["description"] == "dummy-service-description"
Exemplo n.º 2
0
def test_elisa_program_fail():
    with HTTMock(elisaviihde_api_mock, elisaviihde_sso_mock):
        elisa = elisaviihde.elisaviihde(False)
        elisa.login("foo", "bar")
        program = elisa.getprogram(1239)
    assert program["serviceName"] == "dummy-channel-name"
    assert program["description"] == "dummy-service-description"
Exemplo n.º 3
0
 def __init__(self, username, password, formatted_time=False):
     self.elisaviihde = elisaviihde()
     self.formatted_time = formatted_time
     self._dir_cache = {}
     self._stream_uri_cache = {}
     try:
         self.elisaviihde.login(username, password)
     except Exception as error:
         raise ValueError("Invalid credientials") from error
Exemplo n.º 4
0
def test_elisa_watched_fail():
    with HTTMock(elisaviihde_api_mock_badjson, elisaviihde_sso_mock):
        elisa = elisaviihde.elisaviihde(False)
        elisa.login("foo", "bar")
        elisa.markwatched(0)
Exemplo n.º 5
0
def test_elisa_login_fail():
    with HTTMock(elisaviihde_api_mock, elisaviihde_sso_mock_asshole):
        elisa = elisaviihde.elisaviihde(False)
        elisa.login("foo", "bar")
Exemplo n.º 6
0
def test_elisa_recordings():
    with HTTMock(elisaviihde_api_mock, elisaviihde_sso_mock):
        elisa = elisaviihde.elisaviihde(False)
        elisa.login("foo", "bar")
        recordings = elisa.getrecordings(0)
    assert recordings[0]["name"] == "dummy-recording"
Exemplo n.º 7
0
def test_elisa_user_fail():
  with HTTMock(elisaviihde_api_mock_badjson, elisaviihde_sso_mock):
    elisa = elisaviihde.elisaviihde(False)
    elisa.login("foo", "bar")
    user = elisa.getuser()
Exemplo n.º 8
0
def test_elisa_logout_ok():
    with HTTMock(elisaviihde_api_mock, elisaviihde_sso_mock):
        elisa = elisaviihde.elisaviihde(False)
        elisa.login("foo", "bar")
        elisa.close()
    assert elisa.gettoken() == None
Exemplo n.º 9
0
def test_elisa_sessions():
    with HTTMock(elisaviihde_api_mock, elisaviihde_sso_mock):
        elisa = elisaviihde.elisaviihde(False)
        elisa.login("foo", "bar")
        elisa.setsession({"foo": "123"})
        assert elisa.getsession() == {"foo": "123"}
Exemplo n.º 10
0
def test_elisa_user():
    with HTTMock(elisaviihde_api_mock, elisaviihde_sso_mock):
        elisa = elisaviihde.elisaviihde(False)
        elisa.login("foo", "bar")
        user = elisa.getuser()
    assert user["username"] == "dummy-user"
Exemplo n.º 11
0
def test_elisa_sessions():
    with HTTMock(elisaviihde_api_mock, elisaviihde_sso_mock):
        elisa = elisaviihde.elisaviihde(False)
        elisa.login("foo", "bar")
        elisa.setsession({"foo": "123"})
        assert elisa.getsession() == {"foo": "123"}
Exemplo n.º 12
0
def test_elisa_login_fail2():
    with HTTMock(elisaviihde_api_mock_badjson, elisaviihde_sso_mock):
        elisa = elisaviihde.elisaviihde(False)
        elisa.login("foo", "bar")
Exemplo n.º 13
0
def test_elisa_logout_ok():
    with HTTMock(elisaviihde_api_mock, elisaviihde_sso_mock):
        elisa = elisaviihde.elisaviihde(False)
        elisa.login("foo", "bar")
        elisa.close()
    assert elisa.gettoken() == None
Exemplo n.º 14
0
def test_elisa_login_fail():
    with HTTMock(elisaviihde_api_mock, elisaviihde_sso_mock_asshole):
        elisa = elisaviihde.elisaviihde(False)
        elisa.login("foo", "bar")
Exemplo n.º 15
0
try:
    import xbmc
    import xbmcplugin
    import xbmcgui
    import xbmcaddon
    import elisaviihde
    __settings__ = xbmcaddon.Addon(id='plugin.video.elisa.viihde')
    __language__ = __settings__.getLocalizedString
    weekdays = {0: __language__(30006), 1: __language__(30007), 2: __language__(30008),
                3: __language__(30009), 4: __language__(30010), 5: __language__(30011),
                6: __language__(30012)}
except ImportError as err:
    sys.stderr.write(str(err))

# Init Elisa
elisa = elisaviihde.elisaviihde(False)


def get_params():
    param = []
    paramstring = sys.argv[2]
    if len(paramstring) >= 2:
        params = sys.argv[2]
        cleanedparams = params.replace('?', '')
        if (params[len(params) - 1] == '/'):
            params = params[0:len(params) - 2]
        pairsofparams = cleanedparams.split('&')
        param = {}
        for i in range(len(pairsofparams)):
            splitparams = {}
            splitparams = pairsofparams[i].split('=')
Exemplo n.º 16
0
def test_elisa_watched_fail():
  with HTTMock(elisaviihde_api_mock_badjson, elisaviihde_sso_mock):
    elisa = elisaviihde.elisaviihde(False)
    elisa.login("foo", "bar")
    elisa.markwatched(0)
Exemplo n.º 17
0
try:
    import xbmc
    import xbmcplugin
    import xbmcgui
    import xbmcaddon
    import elisaviihde
    __settings__ = xbmcaddon.Addon(id='plugin.video.elisa.viihde')
    __language__ = __settings__.getLocalizedString
    weekdays = {0: __language__(30006), 1: __language__(30007), 2: __language__(30008),
                3: __language__(30009), 4: __language__(30010), 5: __language__(30011),
                6: __language__(30012)}
except ImportError as err:
    sys.stderr.write(str(err))

# Init Elisa
elisa = elisaviihde.elisaviihde(False)


def create_name(prog_data, snippet):
    time_raw = prog_data["startTimeUTC"] / 1000
    weekday_number = int(
        datetime.datetime.fromtimestamp(time_raw).strftime("%w"))
    prog_date = datetime.date.fromtimestamp(time_raw)
    today = datetime.date.today()
    diff = today - prog_date
    if diff.days == 0:
        date_name = __language__(
            30013) + " " + datetime.datetime.fromtimestamp(time_raw).strftime("%H:%M")
    elif diff.days == 1:
        date_name = __language__(
            30014) + " " + datetime.datetime.fromtimestamp(time_raw).strftime("%H:%M")
Exemplo n.º 18
0
def test_elisa_folders():
    with HTTMock(elisaviihde_api_mock, elisaviihde_sso_mock):
        elisa = elisaviihde.elisaviihde(False)
        elisa.login("foo", "bar")
        folders = elisa.getfolders()
    assert folders[0]["name"] == "dummy-folder"
Exemplo n.º 19
0
def main():
  # Parse command line args
  if len(sys.argv[1:]) < 2:
    print "ERROR: Usage:", sys.argv[0], "[-u username]" 
    sys.exit(2)
  try:
    opts, args = getopt.getopt(sys.argv[1:], "u:v", ["username"])
  except getopt.GetoptError as err:
    print "ERROR:", str(err)
    sys.exit(2) 
  
  # Init args
  username = ""
  verbose = False
  
  # Read arg data
  for o, a in opts:
    if o == "-v":
      verbose = True
    elif o in ("-u", "--username"):
      username = a
    else:
      assert False, "unhandled option"
  
  # Ask password securely on command line
  password = getpass.getpass('Password: ')
  
  # Init elisa session
  try:
    elisa = elisaviihde.elisaviihde(verbose)
  except Exception as exp:
    print "ERROR: Could not create elisa session"
    sys.exit(1)
  
  # Login
  try:
    elisa.login(username, password)
  except Exception as exp:
    print "ERROR: Login failed, check username and password"
    sys.exit(1)
  
  # Read and print recording folders
  folders = elisa.getfolders()
  
  print "\nFound folders:"
  for folder in folders:
    print str(folder["id"]) + ": " + folder["name"]
  
  # Read and print recording folders
  folderid = folders[0]["id"]
  recordings = elisa.getrecordings(folderid)
  
  print "\nFound recordings from folder " + str(folderid) + ":"
  for recording in recordings:
    print str(recording["programId"]) + ": " + recording["name"] + " (" + recording["startTimeFormatted"] + ")"
  
  # Get recording stream uri from first recording
  programid = recordings[0]["programId"]
  streamuri = elisa.getstreamuri(programid)
  
  print "\nFound stream uri from recording " + str(programid) + ":"
  print streamuri
  
  # Close session
  elisa.close()
Exemplo n.º 20
0
def test_elisa_recordings():
    with HTTMock(elisaviihde_api_mock, elisaviihde_sso_mock):
        elisa = elisaviihde.elisaviihde(False)
        elisa.login("foo", "bar")
        recordings = elisa.getrecordings(0)
    assert recordings[0]["name"] == "dummy-recording"
Exemplo n.º 21
0
def test_elisa_user():
    with HTTMock(elisaviihde_api_mock, elisaviihde_sso_mock):
        elisa = elisaviihde.elisaviihde(False)
        elisa.login("foo", "bar")
        user = elisa.getuser()
    assert user["username"] == "dummy-user"
Exemplo n.º 22
0
def test_elisa_streamuri():
    with HTTMock(elisaviihde_api_mock, elisaviihde_sso_mock):
        elisa = elisaviihde.elisaviihde(False)
        elisa.login("foo", "bar")
        streamuri = elisa.getstreamuri(0)
    assert streamuri == "http://test.com/test"
Exemplo n.º 23
0
def test_elisa_folders():
    with HTTMock(elisaviihde_api_mock, elisaviihde_sso_mock):
        elisa = elisaviihde.elisaviihde(False)
        elisa.login("foo", "bar")
        folders = elisa.getfolders()
    assert folders[0]["name"] == "dummy-folder"
Exemplo n.º 24
0
def test_elisa_init_fail():
    with HTTMock(elisaviihde_api_mock_asshole):
        elisa = elisaviihde.elisaviihde(False)
Exemplo n.º 25
0
def test_elisa_streamuri():
    with HTTMock(elisaviihde_api_mock, elisaviihde_sso_mock):
        elisa = elisaviihde.elisaviihde(False)
        elisa.login("foo", "bar")
        streamuri = elisa.getstreamuri(0)
    assert streamuri == "http://test.com/test"
Exemplo n.º 26
0
def main():
  # Parse command line args
  if len(sys.argv[1:]) < 2:
    print "ERROR: Usage:", sys.argv[0], "[-u username] [-f outputfile]" 
    sys.exit(2)
  try:
    opts, args = getopt.getopt(sys.argv[1:], "u:f:v", ["username", "outputfile"])
  except getopt.GetoptError as err:
    print "ERROR:", str(err)
    sys.exit(2)
  
  # Init args
  username = ""
  outputfile = "playlist.xspf"
  verbose = False
  
  # Read arg data
  for o, a in opts:
    if o == "-v":
      verbose = True
    elif o in ("-u", "--username"):
      username = a
    elif o in ("-f", "--outputfile"):
      outputfile = a
    else:
      assert False, "unhandled option"
  
  # Ask password securely on command line
  password = getpass.getpass('Password: '******'w')
  filehandle.write(getxmlheader())
  
  # Read top directory and persist to a file
  recordings = elisa.getrecordings(0, 0)
  for recording in recordings:
    streamuri = elisa.getstreamuri(recording["programId"])
    filehandle.write(getxmltrack(None, recording, streamuri).encode('utf8'))

  # Walk sub-directories recursively and persist to a file
  folders = elisa.getfolders()
  for folder in folders:
    recordings = elisa.getrecordings(folder["id"], 0)
    for recording in recordings:
      streamuri = elisa.getstreamuri(recording["programId"])
      filehandle.write(getxmltrack(folder, recording, streamuri).encode('utf8'))
  
  filehandle.write(getxmlfooter())
  filehandle.close()
  
  # Close session
  elisa.close()
Exemplo n.º 27
0
def test_elisa_init_ok():
    with HTTMock(elisaviihde_api_mock):
        elisa = elisaviihde.elisaviihde(False)
    assert elisa.islogged() == False
Exemplo n.º 28
0
def test_elisa_init_ok():
    with HTTMock(elisaviihde_api_mock):
        elisa = elisaviihde.elisaviihde(False)
    assert elisa.islogged() == False
Exemplo n.º 29
0
def test_elisa_login_ok():
    with HTTMock(elisaviihde_api_mock, elisaviihde_sso_mock):
        elisa = elisaviihde.elisaviihde(False)
        elisa.login("foo", "bar")
        assert elisa.islogged() == True
    assert elisa.gettoken() == "dummy-token"
Exemplo n.º 30
0
def test_elisa_init_fail():
    with HTTMock(elisaviihde_api_mock_asshole):
        elisa = elisaviihde.elisaviihde(False)
Exemplo n.º 31
0
def test_elisa_login_fail2():
    with HTTMock(elisaviihde_api_mock_badjson, elisaviihde_sso_mock):
        elisa = elisaviihde.elisaviihde(False)
        elisa.login("foo", "bar")
Exemplo n.º 32
0
def test_elisa_login_ok():
    with HTTMock(elisaviihde_api_mock, elisaviihde_sso_mock):
        elisa = elisaviihde.elisaviihde(False)
        elisa.login("foo", "bar")
        assert elisa.islogged() == True
    assert elisa.gettoken() == "dummy-token"
Exemplo n.º 33
0
def main():
    # Parse command line args
    if len(sys.argv[1:]) < 2:
        print "ERROR: Usage:", sys.argv[0], "[-u username] [-f outputfile]"
        sys.exit(2)
    try:
        opts, args = getopt.getopt(sys.argv[1:], "u:f:v",
                                   ["username", "outputfile"])
    except getopt.GetoptError as err:
        print "ERROR:", str(err)
        sys.exit(2)

    # Init args
    username = ""
    outputfile = "playlist.xspf"
    verbose = False

    # Read arg data
    for o, a in opts:
        if o == "-v":
            verbose = True
        elif o in ("-u", "--username"):
            username = a
        elif o in ("-f", "--outputfile"):
            outputfile = a
        else:
            assert False, "unhandled option"

    # Ask password securely on command line
    password = getpass.getpass('Password: '******'w')
    filehandle.write(getxmlheader())

    # Read top directory and persist to a file
    recordings = elisa.getrecordings(0, 0)
    for recording in recordings:
        streamuri = elisa.getstreamuri(recording["programId"])
        filehandle.write(
            getxmltrack(None, recording, streamuri).encode('utf8'))

    # Walk sub-directories recursively and persist to a file
    folders = elisa.getfolders()
    for folder in folders:
        recordings = elisa.getrecordings(folder["id"], 0)
        for recording in recordings:
            streamuri = elisa.getstreamuri(recording["programId"])
            filehandle.write(
                getxmltrack(folder, recording, streamuri).encode('utf8'))

    filehandle.write(getxmlfooter())
    filehandle.close()

    # Close session
    elisa.close()
Exemplo n.º 34
0
def test_elisa_user_fail():
    with HTTMock(elisaviihde_api_mock_badjson, elisaviihde_sso_mock):
        elisa = elisaviihde.elisaviihde(False)
        elisa.login("foo", "bar")
        user = elisa.getuser()