Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Continuous memory increase with this code #120

Open
neochine opened this issue Jan 19, 2024 · 1 comment
Open

Continuous memory increase with this code #120

neochine opened this issue Jan 19, 2024 · 1 comment

Comments

@neochine
Copy link

image
image

from tmdbv3api.exceptions import TMDbException
from tmdbv3api import TMDb, Movie
from lib.Globals import tmdb_api_key
import time
def scrape_from_tmdb_popular(max_pages=500):
    tmdb = TMDb()
    tmdb.api_key = tmdb_api_key
    tmdb_movie = Movie()
    while True:
        for page in range(1, max_pages):
            popular_movies = tmdb_movie.popular(page=page)
            for popular_movie in popular_movies:
                name, tmdb_id = popular_movie.get('original_title'), popular_movie.get('id')
                print(name)
                if not name or not tmdb_id:
                    print(f"Continuing due to no name or tmdb id")
                    continue
                try:
                    imdb_id = tmdb_movie.external_ids(tmdb_id).get('imdb_id')
                except TMDbException:
                    print(f"Continuing due to no name or imdb id")
                    continue
                except Exception as E:
                    print(f"Continuing due to other error {E}")
                    continue
                time.sleep(1)

scrape_from_tmdb_popular()
@neochine
Copy link
Author

I am using python3.11

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant