diff --git a/README.md b/README.md index 86056be..ea08012 100644 --- a/README.md +++ b/README.md @@ -18,9 +18,9 @@ api=S4GAPI("foo","bar") user_api=api.get_user_api() #get the users from the API -for u in user_api.get_users(): +for u in user_api.get_users(): #for each user, follow the all-thumbnails link by calling the all_thumbnails() function. - for t in u.all_thumbnails()["thumbnails"]: + for t in u.all_thumbnails()["thumbnails"]: print(f"{u.user.user_id};{t.row};{t.col};{t.video_id};{t.timestamp}") ``` @@ -63,7 +63,7 @@ Get the current direct schedule, with metadata from the companion platform-api ```python from s4gpy.s4gpy import S4GAPI api=S4GAPI(,) -for s in api.get_direct_api().get_direct_schedule(): +for s in api.get_direct_api().get_direct_schedule(): try: imdb_data=s.content().imdb_id() genres="+".join([g["genre"] for g in imdb_data.data.genres]) @@ -85,11 +85,11 @@ api=S4GAPI("foo","bar") user_api=api.get_user_api() #for each user -for u in user_api.get_users(): +for u in user_api.get_users(): #get all the video she watched watched_videos=[w.video_id for w in u.all_watches().watches] #for all the thumbnails - for t in u.all_thumbnails()["thumbnails"]: + for t in u.all_thumbnails()["thumbnails"]: #only dump the informations if the user has wached the video if t.video_id in watched_videos: print(f"{u.user.user_id};{t.row};{t.col};{t.video_id};{t.timestamp}") @@ -102,7 +102,7 @@ Get the current direct schedule, with metadata from the companion platform-api ```python from s4gpy.s4gpy import S4GAPI api=S4GAPI(,) -for s in api.get_direct_api().get_direct_schedule(): +for s in api.get_direct_api().get_direct_schedule(): try: imdb_data=s.content().imdb_id() genres="+".join([g["genre"] for g in imdb_data.data.genres]) @@ -120,4 +120,26 @@ Get some credentials for netflix to run a robot run from s4gpy.s4gpy import S4GAPI api=S4GAPI("foo","bar") login, password = api.get_credentials_api().get_credentials("netflix") -``` \ No newline at end of file +``` + + +### Company Mapping API + +Get/Set the mappings for content and company + +```python +from s4gpy.s4gpy import S4GAPI +from s4gpy.api.companyapi import CompanyAPI +from s4gpy.s4gsession import S4GSession +api = S4GAPI("foo","bar") + +api.get_company_api().push_company("company1_cc_code",name="company 1 name",link="company 1 link") +api.get_company_api().push_company("company2_cc_code",name="company 2 name",link="company 2 link") +api.get_company_api().push_content("content_code",["company 1 name","company 2 name"]) + +for company in api.get_company_api().get_companies(): + print(f"company code {company.company_id} is {company.company().name}") +for content in api.get_company_api().get_contents(): + for company in content.content().companies(): + print(f"content {content.content_id} is produced by {company.company_id}") +``` diff --git a/data.csv b/data.csv new file mode 100644 index 0000000..ec2b0fb --- /dev/null +++ b/data.csv @@ -0,0 +1,47 @@ +is_prime_time,is_prime_space,is_most_proposed,freq,airing_time_hour,title,genres,mean_row,mean_col,median_row,media_col,count +False,False,False,0.008770245182766789,7,Equinox,Drama+Fantasy+Mystery+Thriller,4.275280898876405,4.044943820224719,4.0,4.0,178 +False,False,False,0.0003200819409768901,11,Quicksand,Drama,18.833333333333332,6.366666666666666,16.5,3.0,30 +False,False,False,0.00019204916458613405,13,World's Most Wanted,Documentary+Crime,4.475409836065574,7.060109289617486,3,5,183 +False,False,False,0.00012803277639075603,15,No Gogó do Paulinho,Comedy,6.981132075471698,5.773584905660377,6,5,53 +False,False,False,0.00019204916458613405,4,Who Killed Little Gregory?,Documentary+Crime,8.51063829787234,6.035460992907802,5,4,141 +False,False,False,0.0008322130465399142,7,Mank,Biography+Comedy+Drama,5.504065040650406,6.959349593495935,5,4,123 +False,False,False,0.0005761474937584022,5,Mowgli: Legend of the Jungle,Adventure+Drama+Fantasy,10.33673469387755,7.959183673469388,7.5,5.0,98 +False,False,False,0.008898277959157545,9,The Midnight Sky,Drama+Fantasy+Sci-Fi+Thriller,5.123505976095617,2.3446215139442232,4.0,2.0,502 +True,False,False,0.00025606555278151206,19,The Woods,Crime+Drama+Mystery+Thriller,5.431972789115647,4.329931972789115,4.0,4.0,294 +False,False,False,0.014275654567569298,3,Tiny Pretty Things,Drama+Mystery+Thriller,4.34720908230842,3.975402081362346,4,4,1057 +False,False,False,0.0015363933166890724,0,Elite,Crime+Drama+Thriller,6.655765920826162,5.981067125645439,6,4,581 +False,False,False,0.012099097368926445,8,Cobra Kai,Action+Comedy+Drama+Sport,5.509635974304069,4.173447537473233,4.0,3.0,934 +False,False,False,0.0016644260930798285,4,Sex Education,Comedy+Drama,7.865561694290976,6.867403314917127,7,5,543 +False,False,False,0.0009602458229306702,14,Big Mouth,Animation+Comedy+Romance,6.944915254237288,4.262711864406779,5.0,4.0,472 +False,False,False,0.0003840983291722681,12,Young Wallander,Crime+Drama+Mystery+Thriller,5.3628318584070795,7.300884955752212,4.0,4.0,226 +False,False,False,0.0003840983291722681,17,Ragnarok,Drama+Fantasy,12.970588235294118,5.352941176470588,9.0,2.0,102 +False,False,False,0.0014723769284936943,8,Mosul,Action+Drama+War,4.087947882736156,3.550488599348534,3,3,307 +False,False,False,0.0006401638819537802,1,The Rain,Sci-Fi+Thriller,6.893305439330544,4.864016736401673,4.0,3.0,478 +False,False,False,0.00012803277639075603,4,How to Sell Drugs Online (Fast),Comedy+Crime+Drama+Romance,7.2076502732240435,3.9644808743169397,5.0,3.0,366 +False,False,False,0.0008962294347352923,11,Baby,Short+Drama,6.407960199004975,7.437810945273632,4,4,201 +False,False,False,0.00044811471736764613,17,Top Boy,Crime+Drama+Thriller,9.069620253164556,5.284810126582278,7.0,5.0,158 +False,False,False,0.0003840983291722681,18,Don't Listen,Horror+Thriller,5.047169811320755,5.235849056603773,4.0,4.0,106 +False,False,False,0.00044811471736764613,17,The English Game,Drama+History+Sport,12.145348837209303,6.255813953488372,9.0,3.0,172 +True,False,False,0.0008322130465399142,23,Suburra: Blood on Rome,Action+Crime,7.59144893111639,7.104513064133017,6,5,421 +False,False,False,0.0014723769284936943,0,Barbarians,Action+Adventure+Drama+History,5.105732484076433,3.0063694267515926,4,2,785 +False,False,False,0.00044811471736764613,7,The Valhalla Murders,Crime+Drama+Mystery+Thriller,16,6.423076923076923,14.5,4.0,52 +False,True,False,0.026310735548300365,11,Bridgerton,Drama+Romance,3.855252918287938,1.332295719844358,4,1,1285 +False,False,False,0.0029447538569873886,15,Cable Girls,Drama,5.551229508196721,3.9453551912568305,5.0,3.0,1464 +True,False,False,0.00025606555278151206,19,High Seas,Crime+Drama+Mystery,14.829113924050633,8.227848101265822,9.0,4.0,158 +True,False,False,0.0017924588694705845,19,Ma Rainey's Black Bottom,Drama+Music,4.298507462686567,6.149253731343284,4,5,67 +True,False,False,0.004929261891044107,21,Rose Island,Adventure+Comedy+Drama,4.716666666666667,4.088095238095238,3.0,3.0,420 +False,False,False,0.003008770245182767,7,Sweet Home,Drama+Fantasy+Horror+Thriller,4.252964426877471,2.5573122529644268,4,2,253 +False,False,False,0.00025606555278151206,14,Vampires,Drama+Fantasy+Horror,8.941176470588236,2.0588235294117645,4,2,17 +False,False,False,0.0010242622111260482,13,The Prom,Comedy+Drama+Musical,8.537313432835822,6.992537313432836,5.0,4.0,134 +False,False,False,6.401638819537802e-05,17,After Life,Comedy+Drama,8.115702479338843,8.181818181818182,3,4,121 +False,False,False,6.401638819537802e-05,2,White Lines,Drama+Mystery,6.3023255813953485,4.828488372093023,5.0,4.0,344 +False,False,False,6.401638819537802e-05,7,The Eddy,Drama+Musical,5,7.025316455696203,5,4,79 +False,True,False,0.012483195698098713,8,Pieces of a Woman,Drama,3.8505747126436782,5.272030651340996,4,3,261 +False,False,False,0.012035080980731068,14,The Crown,Drama+History,4.279254264180881,2.436334787782626,4,2,2521 +False,False,False,0.0021125408104474747,16,Offering to the Storm,Crime+Thriller,4.333333333333333,3.4482758620689653,3.0,2.0,174 +True,False,False,0.0013443441521029385,19,The Legacy of the Bones,Crime+Thriller,6.169642857142857,6.723214285714286,3.0,5.0,112 +True,False,False,0.0005121311055630241,22,The Hookup Plan,Comedy,7.443526170798898,3.4269972451790633,5,3,363 +False,False,False,0.00019204916458613405,3,GIMS: On the Record,Documentary+Music,7.666666666666667,5.992592592592593,7,3,135 +True,False,False,0.0028167210805966326,19,Money Heist,Action+Crime+Mystery+Thriller,4.767732962447845,3.5931849791376913,4.0,3.0,1438 +False,False,False,0.003904999679918059,7,Virgin River,Drama+Romance,5.919034090909091,4.686079545454546,4.0,4.0,704 +True,False,False,0.0005121311055630241,20,Winter on Fire: Ukraine's Fight for Freedom,Documentary,11.141176470588235,4.235294117647059,12,4,85 diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..b0471b7 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["setuptools", "wheel"] +build-backend = "setuptools.build_meta:__legacy__" \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 57a8683..ae16379 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,46 +1,2 @@ -docutils~=0.16 -lxml~=4.4.2 -pip~=19.3.1 -argparse~=1.4.0 -configparser~=4.0.2 -wheel~=0.33.6 -cryptography~=2.8 -typing~=3.7.4.3 -filelock~=3.0.12 -six~=1.12.0 -packaging~=20.4 -attrs~=19.3.0 -future~=0.18.2 -tqdm~=4.36.1 -requests~=2.25.1 -isort~=4.3.21 -setuptools~=41.4.0 -rfc3986~=1.4.0 -urllib3~=1.25.7 -wcwidth~=0.1.8 -pexpect~=4.8.0 -certifi~=2019.11.28 -chardet~=3.0.4 -idna~=2.8 -pygments~=2.5.2 -pillow~=7.0.0 -sphinx~=3.2.1 -simplejson~=3.17.0 -pyparsing~=2.4.0 -pycparser~=2.19 -snowballstemmer~=2.0.0 -virtualenv~=20.4.0 -distlib~=0.3.1 -appdirs~=1.4.3 -bcrypt~=3.1.7 -zipp~=3.1.0 +requests~=2.25.1 munch~=2.5.0 -sphinx-automodapi==0.13 -sphinx-markdown-tables==0.0.15 -sphinx-rtd-theme==0.5.0 -sphinxcontrib-applehelp==1.0.2 -sphinxcontrib-devhelp==1.0.2 -sphinxcontrib-htmlhelp==1.0.3 -sphinxcontrib-jsmath==1.0.1 -sphinxcontrib-qthelp==1.0.3 -sphinxcontrib-serializinghtml==1.1.4 diff --git a/s4gpy/api/companyapi.py b/s4gpy/api/companyapi.py new file mode 100644 index 0000000..21afaf8 --- /dev/null +++ b/s4gpy/api/companyapi.py @@ -0,0 +1,59 @@ +from munch import munchify + +from s4gpy.api.utils import expand_links + + +class CompanyAPI: + """This class wraps the company-mapper api.""" + + def __init__(self, session): + """Initialize a new CompanyAPI. + + It works by inheriting from the session object of a S4GAPI. + """ + self.session = session + + def get_root(self): + """Get the root of the company mapping api""" + + """return a list of companies links""" + company_links = self.session.get("/").json() + expand_links(self.session, company_links) + return munchify(company_links) + + def get_companies(self): + """Get all the companies in the system""" + return self.get_root().companies() + + def get_contents(self): + """Get all the contents in the systel""" + return self.get_root().contents() + + def get_company(self, id): + """retreives information from a particular company, identified by its cc_code""" + r = self.session.get(f"/company/{id}") + if r.status_code > 299: + return None + company_links = r.json() + expand_links(self.session, company_links) + return munchify(company_links) + + def get_content(self, id): + """retreives information form a particular content, identified by its cc_code""" + r = self.session.get(f"/content/{id}") + if r.status_code > 299: + return None + content_links = r.json() + expand_links(self.session, content_links) + return munchify(content_links) + + def push_company(self, id, name, link): + """Publish a new company.""" + self.session.post(f'/company/{id}', + json={'name': name, 'link': link}) + + def push_content(self, id, company_names): + """Publish a new content associated with some company names.""" + self.session.post(f'/content/{id}', + json={'company_names': [name for name in company_names]}) + diff --git a/s4gpy/api/netflixapi.py b/s4gpy/api/netflixapi.py new file mode 100644 index 0000000..1d1b859 --- /dev/null +++ b/s4gpy/api/netflixapi.py @@ -0,0 +1,22 @@ +from munch import munchify + +from s4gpy.api.utils import expand_links + + +class NetflixAPI: + """This class wraps the netflix-api.""" + + def __init__(self, session): + """Initialize a new NetflixAPI. + + It works by inheriting from the session object of a S4GAPI. + """ + self.session = session + + def get_root(self): + """Publish or updated a new direct schedule.""" + + """returns a list of users.""" + netflix_links = self.session.get("/api/netflix").json() + expand_links(self.session, netflix_links) + return munchify(netflix_links) diff --git a/s4gpy/api/user.py b/s4gpy/api/user.py index 5cfafb5..e79fb7a 100644 --- a/s4gpy/api/user.py +++ b/s4gpy/api/user.py @@ -9,7 +9,7 @@ class UserAPI: """This class wraps the user API""" def __init__(self, session): - """intialiaze a new Credential API""" + """intialiaze a new User API""" self.session = session def get_users(self): diff --git a/s4gpy/api/utils.py b/s4gpy/api/utils.py index 2ffa0aa..33436d0 100644 --- a/s4gpy/api/utils.py +++ b/s4gpy/api/utils.py @@ -8,9 +8,9 @@ def expand_links(session, d): rel = link["rel"] href = link["href"] - def call(address=href): + def call(address=href, **kwargs): - resp = session.get(address) + resp = session.get(address, params=kwargs) if resp.status_code != 200: logging.error(f"calling {address} failed : {resp.status_code}") return "" diff --git a/s4gpy/s4gpy.py b/s4gpy/s4gpy.py index b5d5eee..2fd1c38 100644 --- a/s4gpy/s4gpy.py +++ b/s4gpy/s4gpy.py @@ -6,6 +6,9 @@ from s4gpy.api.credentials import CredentialAPI from s4gpy.api.user import UserAPI from s4gpy.s4gsession import S4GSession +from s4gpy.api.netflixapi import NetflixAPI +from s4gpy.api.companyapi import CompanyAPI + class S4GAPI: @@ -59,6 +62,19 @@ def get_user_api(self): S4GSession( prefix_url=f'{self.protocol}://api.{self.root_dns}', access_token=self.access_token)) + def get_netflix_api(self): + """Return a configured instance of the NetflixAPI.""" + return NetflixAPI( + S4GSession( + prefix_url=f'{self.protocol}://api.{self.root_dns}/api/netflix', + access_token=self.access_token)) + + def get_company_api(self): + """Return a configured instance of the NetflixAPI.""" + return CompanyAPI( + S4GSession( + prefix_url=f'{self.protocol}://imdb-company-mapper.{self.root_dns}/', + access_token=self.access_token)) def get_direct_api(self): """Return a configured instance of the ConsoAPI.""" diff --git a/setup.py b/setup.py index c4c1063..eb4e89a 100644 --- a/setup.py +++ b/setup.py @@ -14,7 +14,7 @@ setup( # Basic project information name='s4gpy', - version='0.0.3', + version='0.0.7', # Authorship and online reference author='Nicolas Herbaut', author_email='nicolas.herbaut@univ-paris1.fr', @@ -24,21 +24,22 @@ long_description=long_description, long_description_content_type='text/markdown', keywords='streaming, recommendation, science', + classifiers=[ 'Development Status :: 4 - Beta', 'Intended Audience :: Developers', 'Natural Language :: English', 'License :: OSI Approved :: Apache Software License', 'Programming Language :: Python', - 'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.7', - 'Programming Language :: Python :: 3.8' + 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.9' ], # Package configuration packages=find_packages(exclude=('tests',)), include_package_data=True, - python_requires='>= 3.6', - install_requires=[], + python_requires='>= 3.7', + install_requires=["requests~=2.25.1", "munch~=2.5.0"], # Licensing and copyright license='Apache 2.0' ) diff --git a/test.csv b/test.csv new file mode 100644 index 0000000..78e5fa1 --- /dev/null +++ b/test.csv @@ -0,0 +1,65 @@ +81075958,{'is_prime_time': False, 'is_prime_space': False, 'is_most_proposed': False, 'freq': 0.008770245182766789, 'airing_time_hour': 7, 'title': 'Equinox', 'genres': 'Drama+Fantasy+Mystery+Thriller', 'mean_row': 4.275280898876405, 'mean_col': 4.044943820224719, 'median_row': 4.0, 'media_col': 4.0, 'count': 'count'} +80211703,{'is_prime_time': False, 'is_prime_space': False, 'is_most_proposed': False, 'freq': 0.0003200819409768901, 'airing_time_hour': 11, 'title': 'Quicksand', 'genres': 'Drama', 'mean_row': 18.833333333333332, 'mean_col': 6.366666666666666, 'median_row': 16.5, 'media_col': 3.0, 'count': 'count'} +80992775,{'is_prime_time': False, 'is_prime_space': 'N/A', 'is_most_proposed': 'N/A', 'freq': 'N/A', 'airing_time_hour': 15, 'title': 'La Révolution', 'genres': 'Action+Adventure+Drama+History+Mystery+Thriller', 'mean_row': 'N/A', 'mean_col': 'N/A', 'median_row': 'N/A', 'media_col': 'N/A', 'count': 'count'} +81013210,{'is_prime_time': False, 'is_prime_space': False, 'is_most_proposed': False, 'freq': 0.00019204916458613405, 'airing_time_hour': 13, 'title': "World's Most Wanted", 'genres': 'Documentary+Crime', 'mean_row': 4.475409836065574, 'mean_col': 7.060109289617486, 'median_row': 3, 'media_col': 5, 'count': 'count'} +81147160,{'is_prime_time': False, 'is_prime_space': 'N/A', 'is_most_proposed': 'N/A', 'freq': 'N/A', 'airing_time_hour': 13, 'title': 'N/A', 'genres': 'N/A', 'mean_row': 'N/A', 'mean_col': 'N/A', 'median_row': 'N/A', 'media_col': 'N/A', 'count': 'count'} +81160045,{'is_prime_time': False, 'is_prime_space': False, 'is_most_proposed': False, 'freq': 0.00012803277639075603, 'airing_time_hour': 15, 'title': 'No Gogó do Paulinho', 'genres': 'Comedy', 'mean_row': 6.981132075471698, 'mean_col': 5.773584905660377, 'median_row': 6, 'media_col': 5, 'count': 'count'} +81071970,{'is_prime_time': False, 'is_prime_space': False, 'is_most_proposed': False, 'freq': 0.0006401638819537802, 'airing_time_hour': 16, 'title': 'N/A', 'genres': 'N/A', 'mean_row': 6.689655172413793, 'mean_col': 5.448275862068965, 'median_row': 5.0, 'media_col': 3.0, 'count': 'count'} +80222157,{'is_prime_time': False, 'is_prime_space': False, 'is_most_proposed': False, 'freq': 0.00019204916458613405, 'airing_time_hour': 4, 'title': 'Who Killed Little Gregory?', 'genres': 'Documentary+Crime', 'mean_row': 8.51063829787234, 'mean_col': 6.035460992907802, 'median_row': 5, 'media_col': 4, 'count': 'count'} +81117189,{'is_prime_time': False, 'is_prime_space': False, 'is_most_proposed': False, 'freq': 0.0008322130465399142, 'airing_time_hour': 7, 'title': 'Mank', 'genres': 'Biography+Comedy+Drama', 'mean_row': 5.504065040650406, 'mean_col': 6.959349593495935, 'median_row': 5, 'media_col': 4, 'count': 'count'} +80993105,{'is_prime_time': False, 'is_prime_space': False, 'is_most_proposed': False, 'freq': 0.0005761474937584022, 'airing_time_hour': 5, 'title': 'Mowgli: Legend of the Jungle', 'genres': 'Adventure+Drama+Fantasy', 'mean_row': 10.33673469387755, 'mean_col': 7.959183673469388, 'median_row': 7.5, 'media_col': 5.0, 'count': 'count'} +80244645,{'is_prime_time': False, 'is_prime_space': False, 'is_most_proposed': False, 'freq': 0.008898277959157545, 'airing_time_hour': 9, 'title': 'The Midnight Sky', 'genres': 'Drama+Fantasy+Sci-Fi+Thriller', 'mean_row': 5.123505976095617, 'mean_col': 2.3446215139442232, 'median_row': 4.0, 'media_col': 2.0, 'count': 'count'} +81108061,{'is_prime_time': True, 'is_prime_space': False, 'is_most_proposed': False, 'freq': 0.00025606555278151206, 'airing_time_hour': 19, 'title': 'The Woods', 'genres': 'Crime+Drama+Mystery+Thriller', 'mean_row': 5.431972789115647, 'mean_col': 4.329931972789115, 'median_row': 4.0, 'media_col': 4.0, 'count': 'count'} +81017308,{'is_prime_time': False, 'is_prime_space': False, 'is_most_proposed': False, 'freq': 0.014275654567569298, 'airing_time_hour': 3, 'title': 'Tiny Pretty Things', 'genres': 'Drama+Mystery+Thriller', 'mean_row': 4.326355851569933, 'mean_col': 3.9695528068506185, 'median_row': 4, 'media_col': 4, 'count': 'count'} +81074662,{'is_prime_time': False, 'is_prime_space': False, 'is_most_proposed': False, 'freq': 0.0003840983291722681, 'airing_time_hour': 5, 'title': 'N/A', 'genres': 'N/A', 'mean_row': 8.31578947368421, 'mean_col': 9.31578947368421, 'median_row': 4, 'media_col': 4, 'count': 'count'} +80200942,{'is_prime_time': False, 'is_prime_space': False, 'is_most_proposed': False, 'freq': 0.0015363933166890724, 'airing_time_hour': 0, 'title': 'Elite', 'genres': 'Crime+Drama+Thriller', 'mean_row': 6.655765920826162, 'mean_col': 5.981067125645439, 'median_row': 6, 'media_col': 4, 'count': 'count'} +81002370,{'is_prime_time': False, 'is_prime_space': False, 'is_most_proposed': False, 'freq': 0.012099097368926445, 'airing_time_hour': 8, 'title': 'Cobra Kai', 'genres': 'Action+Comedy+Drama+Sport', 'mean_row': 5.509635974304069, 'mean_col': 4.173447537473233, 'median_row': 4.0, 'media_col': 3.0, 'count': 'count'} +80197526,{'is_prime_time': False, 'is_prime_space': False, 'is_most_proposed': False, 'freq': 0.0016644260930798285, 'airing_time_hour': 4, 'title': 'Sex Education', 'genres': 'Comedy+Drama', 'mean_row': 7.8640595903165735, 'mean_col': 6.921787709497207, 'median_row': 7, 'media_col': 5, 'count': 'count'} +80117038,{'is_prime_time': False, 'is_prime_space': False, 'is_most_proposed': False, 'freq': 0.0009602458229306702, 'airing_time_hour': 14, 'title': 'Big Mouth', 'genres': 'Animation+Comedy+Romance', 'mean_row': 6.944915254237288, 'mean_col': 4.262711864406779, 'median_row': 5.0, 'media_col': 4.0, 'count': 'count'} +80041653,{'is_prime_time': False, 'is_prime_space': 'N/A', 'is_most_proposed': 'N/A', 'freq': 'N/A', 'airing_time_hour': 18, 'title': 'The Siege of Jadotville', 'genres': 'Action+Drama+History+Thriller+War', 'mean_row': 'N/A', 'mean_col': 'N/A', 'median_row': 'N/A', 'media_col': 'N/A', 'count': 'count'} +81011098,{'is_prime_time': False, 'is_prime_space': False, 'is_most_proposed': False, 'freq': 0.0003840983291722681, 'airing_time_hour': 12, 'title': 'Young Wallander', 'genres': 'Crime+Drama+Mystery+Thriller', 'mean_row': 5.3628318584070795, 'mean_col': 7.300884955752212, 'median_row': 4.0, 'media_col': 4.0, 'count': 'count'} +80232926,{'is_prime_time': False, 'is_prime_space': False, 'is_most_proposed': False, 'freq': 0.0003840983291722681, 'airing_time_hour': 17, 'title': 'Ragnarok', 'genres': 'Drama+Fantasy', 'mean_row': 12.970588235294118, 'mean_col': 5.352941176470588, 'median_row': 9.0, 'media_col': 2.0, 'count': 'count'} +80214886,{'is_prime_time': False, 'is_prime_space': 'N/A', 'is_most_proposed': 'N/A', 'freq': 'N/A', 'airing_time_hour': 7, 'title': 'Paranormal', 'genres': 'Drama+Fantasy+Horror+Mystery+Thriller', 'mean_row': 'N/A', 'mean_col': 'N/A', 'median_row': 'N/A', 'media_col': 'N/A', 'count': 'count'} +81041495,{'is_prime_time': False, 'is_prime_space': False, 'is_most_proposed': False, 'freq': 0.0014723769284936943, 'airing_time_hour': 8, 'title': 'Mosul', 'genres': 'Action+Drama+War', 'mean_row': 4.087947882736156, 'mean_col': 3.550488599348534, 'median_row': 3, 'media_col': 3, 'count': 'count'} +80154610,{'is_prime_time': False, 'is_prime_space': False, 'is_most_proposed': False, 'freq': 0.0006401638819537802, 'airing_time_hour': 1, 'title': 'The Rain', 'genres': 'Sci-Fi+Thriller', 'mean_row': 6.893305439330544, 'mean_col': 4.864016736401673, 'median_row': 4.0, 'media_col': 3.0, 'count': 'count'} +80218448,{'is_prime_time': False, 'is_prime_space': False, 'is_most_proposed': False, 'freq': 0.00012803277639075603, 'airing_time_hour': 4, 'title': 'How to Sell Drugs Online (Fast)', 'genres': 'Comedy+Crime+Drama+Romance', 'mean_row': 7.2076502732240435, 'mean_col': 3.9644808743169397, 'median_row': 5.0, 'media_col': 3.0, 'count': 'count'} +80211634,{'is_prime_time': False, 'is_prime_space': False, 'is_most_proposed': False, 'freq': 0.0008962294347352923, 'airing_time_hour': 11, 'title': 'Baby', 'genres': 'Short+Drama', 'mean_row': 6.407960199004975, 'mean_col': 7.437810945273632, 'median_row': 4, 'media_col': 4, 'count': 'count'} +80217669,{'is_prime_time': False, 'is_prime_space': False, 'is_most_proposed': False, 'freq': 0.00044811471736764613, 'airing_time_hour': 17, 'title': 'Top Boy', 'genres': 'Crime+Drama+Thriller', 'mean_row': 9.069620253164556, 'mean_col': 5.284810126582278, 'median_row': 7.0, 'media_col': 5.0, 'count': 'count'} +81085815,{'is_prime_time': False, 'is_prime_space': False, 'is_most_proposed': False, 'freq': 0.0003840983291722681, 'airing_time_hour': 18, 'title': "Don't Listen", 'genres': 'Horror+Thriller', 'mean_row': 5.047169811320755, 'mean_col': 5.235849056603773, 'median_row': 4.0, 'media_col': 4.0, 'count': 'count'} +80244928,{'is_prime_time': False, 'is_prime_space': False, 'is_most_proposed': False, 'freq': 0.00044811471736764613, 'airing_time_hour': 17, 'title': 'The English Game', 'genres': 'Drama+History+Sport', 'mean_row': 12.341317365269461, 'mean_col': 6.263473053892215, 'median_row': 9, 'media_col': 3, 'count': 'count'} +80081537,{'is_prime_time': True, 'is_prime_space': False, 'is_most_proposed': False, 'freq': 0.0008322130465399142, 'airing_time_hour': 23, 'title': 'Suburra: Blood on Rome', 'genres': 'Action+Crime', 'mean_row': 7.59144893111639, 'mean_col': 7.104513064133017, 'median_row': 6, 'media_col': 5, 'count': 'count'} +81024039,{'is_prime_time': False, 'is_prime_space': False, 'is_most_proposed': False, 'freq': 0.0014723769284936943, 'airing_time_hour': 0, 'title': 'Barbarians', 'genres': 'Action+Adventure+Drama+History', 'mean_row': 5.105732484076433, 'mean_col': 3.0063694267515926, 'median_row': 4, 'media_col': 2, 'count': 'count'} +81083590,{'is_prime_time': False, 'is_prime_space': False, 'is_most_proposed': False, 'freq': 0.0033928685743550347, 'airing_time_hour': 3, 'title': 'N/A', 'genres': 'N/A', 'mean_row': 4.534526854219949, 'mean_col': 4.820971867007673, 'median_row': 3, 'media_col': 3, 'count': 'count'} +81043833,{'is_prime_time': False, 'is_prime_space': False, 'is_most_proposed': False, 'freq': 0.00044811471736764613, 'airing_time_hour': 7, 'title': 'The Valhalla Murders', 'genres': 'Crime+Drama+Mystery+Thriller', 'mean_row': 16, 'mean_col': 6.423076923076923, 'median_row': 14.5, 'media_col': 4.0, 'count': 'count'} +80232398,{'is_prime_time': False, 'is_prime_space': True, 'is_most_proposed': False, 'freq': 0.026310735548300365, 'airing_time_hour': 11, 'title': 'Bridgerton', 'genres': 'Drama+Romance', 'mean_row': 3.8428908091123333, 'mean_col': 1.3448546739984288, 'median_row': 4, 'media_col': 1, 'count': 'count'} +80100929,{'is_prime_time': False, 'is_prime_space': False, 'is_most_proposed': False, 'freq': 0.0029447538569873886, 'airing_time_hour': 15, 'title': 'Cable Girls', 'genres': 'Drama', 'mean_row': 5.551229508196721, 'mean_col': 3.9453551912568305, 'median_row': 5.0, 'media_col': 3.0, 'count': 'count'} +80233258,{'is_prime_time': True, 'is_prime_space': False, 'is_most_proposed': False, 'freq': 0.00025606555278151206, 'airing_time_hour': 19, 'title': 'High Seas', 'genres': 'Crime+Drama+Mystery', 'mean_row': 14.829113924050633, 'mean_col': 8.227848101265822, 'median_row': 9.0, 'media_col': 4.0, 'count': 'count'} +81100780,{'is_prime_time': True, 'is_prime_space': False, 'is_most_proposed': False, 'freq': 0.0017924588694705845, 'airing_time_hour': 19, 'title': "Ma Rainey's Black Bottom", 'genres': 'Drama+Music', 'mean_row': 4.298507462686567, 'mean_col': 6.149253731343284, 'median_row': 4, 'media_col': 5, 'count': 'count'} +81116948,{'is_prime_time': True, 'is_prime_space': False, 'is_most_proposed': False, 'freq': 0.004929261891044107, 'airing_time_hour': 21, 'title': 'Rose Island', 'genres': 'Adventure+Comedy+Drama', 'mean_row': 4.716666666666667, 'mean_col': 4.088095238095238, 'median_row': 3.0, 'media_col': 3.0, 'count': 'count'} +80202347,{'is_prime_time': False, 'is_prime_space': True, 'is_most_proposed': False, 'freq': 0.0006401638819537802, 'airing_time_hour': 2, 'title': 'N/A', 'genres': 'N/A', 'mean_row': 2.3461538461538463, 'mean_col': 5.269230769230769, 'median_row': 1.0, 'media_col': 2.0, 'count': 'count'} +81061734,{'is_prime_time': False, 'is_prime_space': False, 'is_most_proposed': False, 'freq': 0.003008770245182767, 'airing_time_hour': 7, 'title': 'Sweet Home', 'genres': 'Drama+Fantasy+Horror+Thriller', 'mean_row': 4.252964426877471, 'mean_col': 2.5573122529644268, 'median_row': 4, 'media_col': 2, 'count': 'count'} +81140803,{'is_prime_time': False, 'is_prime_space': 'N/A', 'is_most_proposed': 'N/A', 'freq': 'N/A', 'airing_time_hour': 9, 'title': 'N/A', 'genres': 'N/A', 'mean_row': 'N/A', 'mean_col': 'N/A', 'median_row': 'N/A', 'media_col': 'N/A', 'count': 'count'} +80222720,{'is_prime_time': False, 'is_prime_space': False, 'is_most_proposed': False, 'freq': 0.00025606555278151206, 'airing_time_hour': 14, 'title': 'Vampires', 'genres': 'Drama+Fantasy+Horror', 'mean_row': 8.941176470588236, 'mean_col': 2.0588235294117645, 'median_row': 4, 'media_col': 2, 'count': 'count'} +80200575,{'is_prime_time': False, 'is_prime_space': False, 'is_most_proposed': False, 'freq': 0.008130081300813009, 'airing_time_hour': 14, 'title': 'N/A', 'genres': 'N/A', 'mean_row': 4.713010204081633, 'mean_col': 3.061224489795918, 'median_row': 4.0, 'media_col': 3.0, 'count': 'count'} +81033361,{'is_prime_time': False, 'is_prime_space': False, 'is_most_proposed': False, 'freq': 0.007169835477882338, 'airing_time_hour': 12, 'title': 'N/A', 'genres': 'N/A', 'mean_row': 5.421356421356421, 'mean_col': 2.8917748917748916, 'median_row': 4, 'media_col': 2, 'count': 'count'} +81079914,{'is_prime_time': False, 'is_prime_space': False, 'is_most_proposed': False, 'freq': 0.0010242622111260482, 'airing_time_hour': 13, 'title': 'The Prom', 'genres': 'Comedy+Drama+Musical', 'mean_row': 8.716666666666667, 'mean_col': 7.408333333333333, 'median_row': 5.0, 'media_col': 4.5, 'count': 'count'} +80998491,{'is_prime_time': False, 'is_prime_space': False, 'is_most_proposed': False, 'freq': 6.401638819537802e-05, 'airing_time_hour': 17, 'title': 'After Life', 'genres': 'Comedy+Drama', 'mean_row': 8.115702479338843, 'mean_col': 8.181818181818182, 'median_row': 3, 'media_col': 4, 'count': 'count'} +80189898,{'is_prime_time': True, 'is_prime_space': 'N/A', 'is_most_proposed': 'N/A', 'freq': 'N/A', 'airing_time_hour': 20, 'title': 'Osmosis', 'genres': 'Romance+Sci-Fi', 'mean_row': 'N/A', 'mean_col': 'N/A', 'median_row': 'N/A', 'media_col': 'N/A', 'count': 'count'} +80198508,{'is_prime_time': True, 'is_prime_space': 'N/A', 'is_most_proposed': 'N/A', 'freq': 'N/A', 'airing_time_hour': 21, 'title': 'Girls with Balls', 'genres': 'Comedy+Horror', 'mean_row': 'N/A', 'mean_col': 'N/A', 'median_row': 'N/A', 'media_col': 'N/A', 'count': 'count'} +80993591,{'is_prime_time': False, 'is_prime_space': False, 'is_most_proposed': False, 'freq': 6.401638819537802e-05, 'airing_time_hour': 2, 'title': 'White Lines', 'genres': 'Drama+Mystery', 'mean_row': 6.3023255813953485, 'mean_col': 4.828488372093023, 'median_row': 5.0, 'media_col': 4.0, 'count': 'count'} +80197844,{'is_prime_time': False, 'is_prime_space': False, 'is_most_proposed': False, 'freq': 6.401638819537802e-05, 'airing_time_hour': 7, 'title': 'The Eddy', 'genres': 'Drama+Musical', 'mean_row': 5, 'mean_col': 7.025316455696203, 'median_row': 5, 'media_col': 4, 'count': 'count'} +81128745,{'is_prime_time': False, 'is_prime_space': True, 'is_most_proposed': False, 'freq': 0.012483195698098713, 'airing_time_hour': 8, 'title': 'Pieces of a Woman', 'genres': 'Drama', 'mean_row': 3.8505747126436782, 'mean_col': 5.272030651340996, 'median_row': 4, 'media_col': 3, 'count': 'count'} +80025678,{'is_prime_time': False, 'is_prime_space': False, 'is_most_proposed': False, 'freq': 0.012035080980731068, 'airing_time_hour': 14, 'title': 'The Crown', 'genres': 'Drama+History', 'mean_row': 4.279254264180881, 'mean_col': 2.436334787782626, 'median_row': 4, 'media_col': 2, 'count': 'count'} +80141173,{'is_prime_time': False, 'is_prime_space': 'N/A', 'is_most_proposed': 'N/A', 'freq': 'N/A', 'airing_time_hour': 15, 'title': '100 metros', 'genres': 'Biography+Comedy+Drama', 'mean_row': 'N/A', 'mean_col': 'N/A', 'median_row': 'N/A', 'media_col': 'N/A', 'count': 'count'} +80990328,{'is_prime_time': False, 'is_prime_space': False, 'is_most_proposed': False, 'freq': 0.0021125408104474747, 'airing_time_hour': 16, 'title': 'Offering to the Storm', 'genres': 'Crime+Thriller', 'mean_row': 4.333333333333333, 'mean_col': 3.4482758620689653, 'median_row': 3.0, 'media_col': 2.0, 'count': 'count'} +80990327,{'is_prime_time': True, 'is_prime_space': False, 'is_most_proposed': False, 'freq': 0.0013443441521029385, 'airing_time_hour': 19, 'title': 'The Legacy of the Bones', 'genres': 'Crime+Thriller', 'mean_row': 6.169642857142857, 'mean_col': 6.723214285714286, 'median_row': 3.0, 'media_col': 5.0, 'count': 'count'} +80190086,{'is_prime_time': True, 'is_prime_space': False, 'is_most_proposed': False, 'freq': 0.0005121311055630241, 'airing_time_hour': 22, 'title': 'The Hookup Plan', 'genres': 'Comedy', 'mean_row': 7.443526170798898, 'mean_col': 3.4269972451790633, 'median_row': 5, 'media_col': 3, 'count': 'count'} +80217779,{'is_prime_time': False, 'is_prime_space': 'N/A', 'is_most_proposed': 'N/A', 'freq': 'N/A', 'airing_time_hour': 2, 'title': 'Marianne', 'genres': 'Horror', 'mean_row': 'N/A', 'mean_col': 'N/A', 'median_row': 'N/A', 'media_col': 'N/A', 'count': 'count'} +81029777,{'is_prime_time': False, 'is_prime_space': False, 'is_most_proposed': False, 'freq': 0.00019204916458613405, 'airing_time_hour': 3, 'title': 'GIMS: On the Record', 'genres': 'Documentary+Music', 'mean_row': 7.666666666666667, 'mean_col': 5.992592592592593, 'median_row': 7, 'media_col': 3, 'count': 'count'} +80994082,{'is_prime_time': False, 'is_prime_space': True, 'is_most_proposed': False, 'freq': 0.013123359580052493, 'airing_time_hour': 12, 'title': 'N/A', 'genres': 'N/A', 'mean_row': 3.5925085130533483, 'mean_col': 0.8024971623155505, 'median_row': 4, 'media_col': 0, 'count': 'count'} +81078137,{'is_prime_time': False, 'is_prime_space': 'N/A', 'is_most_proposed': 'N/A', 'freq': 'N/A', 'airing_time_hour': 15, 'title': 'N/A', 'genres': 'N/A', 'mean_row': 'N/A', 'mean_col': 'N/A', 'median_row': 'N/A', 'media_col': 'N/A', 'count': 'count'} +80192098,{'is_prime_time': True, 'is_prime_space': False, 'is_most_proposed': False, 'freq': 0.0028167210805966326, 'airing_time_hour': 19, 'title': 'Money Heist', 'genres': 'Action+Crime+Mystery+Thriller', 'mean_row': 4.767732962447845, 'mean_col': 3.5931849791376913, 'median_row': 4.0, 'media_col': 3.0, 'count': 'count'} +81010965,{'is_prime_time': True, 'is_prime_space': False, 'is_most_proposed': False, 'freq': 0.0007041802701491581, 'airing_time_hour': 23, 'title': 'N/A', 'genres': 'N/A', 'mean_row': 8.608695652173912, 'mean_col': 19.782608695652176, 'median_row': 9, 'media_col': 22, 'count': 'count'} +80240027,{'is_prime_time': False, 'is_prime_space': False, 'is_most_proposed': False, 'freq': 0.003904999679918059, 'airing_time_hour': 7, 'title': 'Virgin River', 'genres': 'Drama+Romance', 'mean_row': 5.919034090909091, 'mean_col': 4.686079545454546, 'median_row': 4.0, 'media_col': 4.0, 'count': 'count'} +80242292,{'is_prime_time': False, 'is_prime_space': False, 'is_most_proposed': False, 'freq': 0.00044811471736764613, 'airing_time_hour': 12, 'title': 'N/A', 'genres': 'N/A', 'mean_row': 10.914285714285715, 'mean_col': 9.314285714285715, 'median_row': 4, 'media_col': 3, 'count': 'count'} +80031666,{'is_prime_time': True, 'is_prime_space': False, 'is_most_proposed': False, 'freq': 0.0005121311055630241, 'airing_time_hour': 20, 'title': "Winter on Fire: Ukraine's Fight for Freedom", 'genres': 'Documentary', 'mean_row': 11.141176470588235, 'mean_col': 4.235294117647059, 'median_row': 12, 'media_col': 4, 'count': 'count'} diff --git a/tests/test_utils.py b/tests/test_utils.py index 1d5912f..2ca70e6 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -1,13 +1,17 @@ """qsdfqsdfqsdf.""" from s4gpy.s4gpy import S4GAPI +from s4gpy.api.companyapi import CompanyAPI +from s4gpy.s4gsession import S4GSession class TestUtils: """qsdfqsdfqsdf.""" def testing(self): - api = S4GAPI("user1", "user") - users = api.get_user_api().get_users() - watches = users[0].all_watches() - print(watches) + + from s4gpy.s4gpy import S4GAPI + from s4gpy.api.companyapi import CompanyAPI + from s4gpy.s4gsession import S4GSession + api = CompanyAPI(S4GSession(prefix_url=f'http://localhost:5000/', access_token="")) + api.get_root().companies()