def test_kwargs(self): """ This function tests the kwargs for the MslClient initialization to make sure that they are properly set """ esn = 'NFCDIE-02-TDP0LTTSNSC3EHLL71FRYFOEEAZYQ3' drm_system = 'playready' profiles = ['ddplus-5.1-dash'] #keypair = RSA.generate(2048) message_id = 123456789 languages = ['de-DE'] client = pymsl.MslClient( {'scheme': 'EMAIL_PASSWORD'}, esn=esn, drm_system=drm_system, profiles=profiles, #keypair=keypair, message_id=message_id, languages=languages ) self.assertEqual(esn, client.msl_session['esn']) self.assertEqual(drm_system, client.msl_session['drm_system']) self.assertEqual(profiles, client.msl_session['profiles']) #self.assertEqual(keypair, client.msl_session['keypair']) self.assertEqual(message_id, client.msl_session['message_id']) self.assertEqual(languages, client.msl_session['languages'])
def main(argv): assert (len(argv)) == 1 DATA_FILE = argv[0] NFLIXLOCATION = "NFLIXLOCATION" NFLIXACCOUNTS = "NFLIXACCOUNTS" NFLIXMOVIES = "NFLIXMOVIES" file_path = os.path.dirname(os.path.realpath(__file__)) + '/' + DATA_FILE # reads current rankings data from disk try: file = open(file_path, 'rb') data = pickle.load(file) file.close() except FileNotFoundError: data = {} # retrieve cdn rankings location = os.environ[NFLIXLOCATION] account_numer = 1 accounts = os.environ[NFLIXACCOUNTS].split(',') total = len(accounts) for account in accounts: email, password = account.split(':') print("getting data for account " + str(account_numer) + " of " + str(total)) user_auth_data = { 'scheme': 'EMAIL_PASSWORD', 'authdata': { 'email': email, 'password': password } } client = pymsl.MslClient(user_auth_data) for movie in os.environ[NFLIXMOVIES].split(','): cdns = client.load_manifest(int(movie))["result"]["servers"] for c in cdns: data.setdefault(location, {}).setdefault(movie, {}).setdefault( c['rank'], {})[str(account_numer)] = c account_numer += 1 # write back data to disk file = open(file_path, "wb") pickle.dump(data, file, protocol=pickle.HIGHEST_PROTOCOL) file.close()
def test_manifest_exception(self): """Test for ManifestError exception""" client = pymsl.MslClient({'scheme': 'EMAIL_PASSWORD'}) self.assertRaises(ManifestError, client.load_manifest, 80092521)
def test_license_exception(self): """Test for LicenseError exception""" client = pymsl.MslClient({'scheme': 'EMAIL_PASSWORD'}) self.assertRaises(LicenseError, client.get_license, b'')