def test_user_list(): sean = User("sean") assert all([isinstance(l, UserList) for l in sean.lists]) data = dict( name="Star Wars in machete order", description="Some descriptive text", privacy="public", display_numbers=True ) # create list l = UserList.create(creator=sean.username, **data) for k, v in data.items(): assert getattr(l, k) == v # get list l = UserList.get(data["name"], sean.username) l = sean.get_list(data["name"]) for k, v in data.items(): assert getattr(l, k) == v # PUT to add and remove items from list l.add_items() for k, v in data.items(): assert getattr(l, k) == v l.remove_items() for k, v in data.items(): assert getattr(l, k) == v # like and unlike a list l.like() l.unlike() # just test to ensure that iterating over list items works l.__iter__() # delete entire list l.delete_list()
def test_watching(): sean = User("sean") sean.username = "******" assert isinstance(sean.watching, Movie) sean.username = "******" assert isinstance(sean.watching, TVEpisode) sean.username = "******" assert sean.watching is None
def test_watching(): sean = User('sean') sean.username = '******' assert isinstance(sean.watching, Movie) sean.username = '******' assert isinstance(sean.watching, TVEpisode) sean.username = '******' assert sean.watching is None
def watching_now(self): """A list of all :class:`User`'s watching a movie.""" from trakt.users import User data = yield self.ext + '/watching' users = [] for user in data: users.append(User(**user)) yield users
def get_trakt_user(self, username): try: return User(username) except Exception as e: self._error_and_analytics( error_message=f"Error in get_trakt_user: {e}", function_name=inspect.currentframe().f_code.co_name) return None
def test_requests(): getters = [get_all_requests, User('sean').get_follower_requests] for getter in getters: requests = getter() assert isinstance(requests, list) assert all([isinstance(r, Request) for r in requests]) for request in requests: r = request.approve() assert r is None r = request.deny() assert r is None
def test_user_list(): sean = User('sean') assert all([isinstance(l, UserList) for l in sean.lists]) data = dict(name='Star Wars in machete order', description='Some descriptive text', privacy='public', display_numbers=True) # create list l = UserList.create(creator=sean.username, **data) for k, v in data.items(): assert getattr(l, k) == v # get list l = UserList.get(data['name'], sean.username) l = sean.get_list(data['name']) for k, v in data.items(): assert getattr(l, k) == v # enumerate list items instancetypes = (Movie, TVShow, TVSeason, TVEpisode, Person) assert all([isinstance(k, instancetypes) for k in l]) # PUT to add and remove items from list l.add_items() for k, v in data.items(): assert getattr(l, k) == v l.remove_items() for k, v in data.items(): assert getattr(l, k) == v # like and unlike a list l.like() l.unlike() # just test to ensure that iterating over list items works l.__iter__() # delete entire list l.delete_list()
def comments(self): """All comments (shouts and reviews) for this :class:`Movie`. Most recent comments returned first. """ # TODO (jnappi) Pagination from trakt.users import User data = yield (self.ext + '/comments') self._comments = [] for com in data: user = User(**com.get('user')) self._comments.append( Comment(user=user, **{k: com[k] for k in com if k != 'user'}) ) yield self._comments
def getTraktShows(syncUser): my = User(syncUser.getTraktUserName()) for y in range(len(my.watched_shows)): dict = my.watched_shows[y].seasons[-1] # gets the episodes (change to -1 to get current season value # -2 gets all teh episodes you've watched fKey = dict.keys()[-2] values = dict[fKey] last_episode_watched = values[-1] episode_Number = last_episode_watched['number'] date_Watched_At = last_episode_watched['last_watched_at'] traktShow = TvShow(my.watched_shows[y].title, date_Watched_At, episode_Number) syncUser.addShow(traktShow)
def login(self): try: username = self.ids.username.text global moviesDB moviesDB = imdb.IMDb() myuser = User(str(username)) global watchlist watchlist = myuser.watchlist_movies global myline try: dataget() # after you get new values update the variables connected to widgets except: print('Error') dataget() self.manager.current = "giris_basarili" except: self.manager.current = "giris_hatali"
def getTraktShows(syncUser): my = User(syncUser.getTraktUserName()) for y in range(len(my.watched_shows)): theDict = my.watched_shows[y].seasons[-1] # # gets the episodes (change to -1 to get current season value # # -2 gets all teh episodes you've watched fKey = list(theDict.keys())[-2] #dictionaries change the first value on a whim, sometimes its episodes sometimes its numbers if(fKey == "number"): fKey = list(theDict.keys())[-1] values = theDict[fKey] last_episode_watched = values[-1] episode_Number = last_episode_watched['number'] date_Watched_At = last_episode_watched['last_watched_at'] traktShow = TvShow(my.watched_shows[y].title, date_Watched_At, episode_Number); syncUser.addShow(traktShow)
def getTraktShows(): allShows = [] my = User(settings['Users']['Smoothtalk']['traktUserName']) for y in range(len(my.watched_shows)): dict = my.watched_shows[y].seasons[-1] # gets the episodes (change to -1 to get current season value # -2 gets all teh episodes you've watched fKey = dict.keys()[-2] values = dict[fKey] last_episode_watched = values[-1] episode_Number = last_episode_watched['number'] date_Watched_At = last_episode_watched['last_watched_at'] traktShow = TvShow() traktShow.setTitle(my.watched_shows[y]) traktShow.setLast_watched_date(date_Watched_At) traktShow.setlast_watched_episode(episode_Number) allShows.append(traktShow) return allShows
def getTraktShows(settings): allShows = [] for user in settings['Users']: if(settings['Users'][user]['traktUserName'] != ''): my = User(settings['Users'][user]['traktUserName']) for y in range(len(my.watched_shows)): theDict = my.watched_shows[y].seasons[-1] # gets the episodes (change to -1 to get current season value) # -2 gets all the episodes you've watched #MIGHT NOT WORK values = theDict['episodes'] last_episode_watched = values[-1] episode_Number = last_episode_watched['number'] date_Watched_At = last_episode_watched['last_watched_at'] traktShow = TvShow(); traktShow.setTitle(my.watched_shows[y]) traktShow.setLast_watched_date(date_Watched_At) traktShow.setlast_watched_episode(episode_Number) allShows.append(traktShow) return allShows
pass exit(0) signal.signal(signal.SIGINT, signal_handler) start = time.time() if len(argv) != 3: print("Usage: ./trakt_discord.py [username] [Discord_client_ID]") else: username = argv[1] trakt_connected = False while not trakt_connected: try: my = User(username) trakt_connected = True print(time.strftime("%Y-%m-%dT%H:%M:%S.000%Z"), ": Successfully connected to Trakt") except Exception: print(time.strftime("%Y-%m-%dT%H:%M:%S.000%Z"), ": Trakt Connection Failure (1)") time.sleep(15) client_id = argv[2] # force this script to live on an island and catch the errors # I don't want to see a command prompt when I'm expecting this to keep going # Spit an error for OSError: [Errno 107] Transport endpoint is not connecte # Discord has to be running before this is--duh rpc_obj = rpc.DiscordIpcClient.for_platform(client_id) while True: try:
def test_stats(): sean = User('sean') assert isinstance(sean.get_stats(), dict)
def test_user_ratings(): sean = User("sean") rating_types = ["movies", "shows", "seasons", "episodes"] for typ in rating_types: assert all([isinstance(r, dict) for r in sean.get_ratings(typ)]) assert all([isinstance(r, dict) for r in sean.get_ratings("movies", 10)])
def test_user(): sean = User('sean') assert sean.username == 'sean' assert str(sean) == '<User>: sean'
def test_follow_user(): sean = User("sean") sean.follow() sean.unfollow()
def test_user_collections(): sean = User('sean') for _ in range(2): assert all([isinstance(m, Movie) for m in sean.movie_collection]) assert all([isinstance(s, TVShow) for s in sean.show_collection])
def test_stats(): sean = User("sean") assert isinstance(sean.get_stats(), dict)
def test_get_others(): sean = User('sean') for _ in range(2): assert all([isinstance(u, User) for u in sean.followers]) assert all([isinstance(u, User) for u in sean.following]) assert all([isinstance(u, User) for u in sean.friends])
def test_follow_user(): sean = User('sean') sean.follow() sean.unfollow()
def get_user(): return User('shrijit')
def get_trakt_user(self, username): try: return User(username) except Exception as e: self._error_and_analytics(error_message=f"Error in get_trakt_user: {e}", function_name='get_trakt_user') return None
if username is None: quit() else: if username is "": username = tk.simpledialog.askstring( "Empty Value", " Please Enter A Valid Username: "******"": quit() popup.destroy() ## IMDB, Trakt.TV Tanımları moviesDB = imdb.IMDb() my = User(str('lunedor')) ## Trakt.tv Watchlist Alımı watchlist = my.watchlist_movies # Veri İşlemleri def callback(): ### Terimler myline = str(random.choice(watchlist))[9:1000] movies = moviesDB.search_movie(str(myline)) id = movies[0].getID() movie = moviesDB.get_movie(id) title = movie['title'] year = movie["year"] rating = movie["rating"] runtimes = movie["runtimes"]
def test_watched(): sean = User('sean') for _ in range(2): assert all([isinstance(m, Movie) for m in sean.watched_movies]) assert all([isinstance(s, TVShow) for s in sean.watched_shows])
def test_user_ratings(): sean = User('sean') rating_types = ['movies', 'shows', 'seasons', 'episodes'] for typ in rating_types: assert all([isinstance(r, dict) for r in sean.get_ratings(typ)]) assert all([isinstance(r, dict) for r in sean.get_ratings('movies', 10)])