Skip to content

Commit

Permalink
Merge pull request #58 from mBaratta96/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
mBaratta96 authored Feb 26, 2024
2 parents d15ccc4 + 414eed8 commit 88f2814
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 10 deletions.
4 changes: 1 addition & 3 deletions letterboxd_stats/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@
from letterboxd_stats import tmdb
import os
from letterboxd_stats import config
from pandarallel import pandarallel
from tqdm import tqdm

pandarallel.initialize(verbose=0)
tqdm.pandas(desc="Fetching ids...")


Expand Down Expand Up @@ -91,7 +89,7 @@ def _show_lists(df: pd.DataFrame, ascending: bool) -> pd.DataFrame:
avg = {"Rating Mean": "{:.2f}".format(df["Rating"].mean())}
if config["TMDB"]["get_list_runtimes"] is True:
ids = df["Url"].progress_map(get_tmdb_id)
df["Duration"] = ids.parallel_map(lambda id: tmdb.get_film_duration(id)) # type: ignore
df["Duration"] = ids.map(lambda id: tmdb.get_film_duration(id)) # type: ignore
avg["Time-weighted Rating Mean"] = "{:.2f}".format(
((df["Duration"] / df["Duration"].sum()) * df["Rating"]).sum()
)
Expand Down
2 changes: 1 addition & 1 deletion letterboxd_stats/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def try_command(command, args):
try:
command(*args)
except Exception as e:
raise e
print(e)


def check_path(path: str):
Expand Down
6 changes: 2 additions & 4 deletions letterboxd_stats/tmdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,12 @@
from tmdbv3api.objs.account import AsObj
from letterboxd_stats import cli
from letterboxd_stats import config
from pandarallel import pandarallel

tmdb = TMDb()
tmdb.api_key = config["TMDB"]["api_key"]
person = Person()
movie = Movie()
search = Search()
pandarallel.initialize(verbose=0)


def get_person(name: str) -> Tuple[pd.DataFrame, str]:
Expand Down Expand Up @@ -48,10 +46,10 @@ def get_person(name: str) -> Tuple[pd.DataFrame, str]:
)
df = df[df["Department"] == department]
df = df.drop("Department", axis=1)
# person.details provides movies without time duration. If the user wants
# person.details provides movies without time duration. If the user wants<S-D-A>
# (since this slows down the process) get with the movie.details API.
if config["TMDB"]["get_list_runtimes"] is True:
df["Duration"] = df.index.to_series().parallel_map(get_film_duration) # type: ignore
df["Duration"] = df.index.to_series().map(get_film_duration) # type: ignore
return df, p["name"]


Expand Down
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ dependencies = [
"ascii_magic~=2.3.0",
"inquirerpy~=0.3.4",
"lxml~=4.9.0",
"pandas~=1.5.1",
"pandarallel~=1.6.5",
"pandas~=2.2.1",
"platformdirs~=3.0.0",
"requests~=2.31.0",
"rich~=13.3.5",
Expand Down

0 comments on commit 88f2814

Please sign in to comment.