r/learnpython • • Sep 04 '26

Help me code a movie selector!

Hi all, new to Python and for my first project I'm trying to code a program that will randomly select a movie or tv show using a pre-made list, and a "genre" plus "media type" as input.

I feel I am over complicating it.

Here's where I'm at so far:

def media_selector(media, genre):
### attempting to remove previously selected titles and for some reason make my own RNG \/###
increment = + 1
trans_rng = [1, 2]
genre = ['romance', 'action']
movie_list = ['rango', 'taxi driver']
series_list = ['akira', 'trigun']
### spell check, obviously \/###
spell_check = ['film', 'movie', 'tv show', 'tv series', 'tv', 'romance', 'action']
if not isinstance(media, str):
return 'format is: media type, genre'
### not sure if i should be defining a function and calling it at the same time - also is a translation table too much ? \/###
if media and genre is (spell_check):
def media_decider():
movie_trans_tbl = movie_list.maketrans(movie_list, trans_rng)
movie_transd = movie_list.translate(movie_trans_tbl)
series_trans_tbl = series_list.maketrans(series_list, trans_rng)
series_transd = series_list.translate(series_trans_tbl)
selector = slice(increment)
else:
return 'film/movie or tv show/tv series'

any guidance/recommended resources would be greatly appreciated!

0 Upvotes

13 comments sorted by

View all comments

Show parent comment

1

u/lakseol Sep 06 '26

I see many suggestions in the comments, such as using a CSV data format, storing data on disk, etc. You are just starting out so do as others have said, start simple. That means keeping all data in a data structure in code, like a list of tuples. Experiment with different ways of storing data in code, see how that changes how you manipulate that data.

The next big step is when you want to make your data persistent. Your program should save data to a file so the next time your program runs it reads that data and processes it. You have to decide how to store the data on disk, in "pickle" form, JSON, CSV or something else. You really want to make that save/load code modular so most of your code doesn't know or care how the data is stored on disk. This makes it easy to change how you store the data on disk when you try something different.

The next big thing might be to use an actual database. You can use the builtin sqlite database. Now you don't need any python code to select movies with a given genre/medium - you do it all in an SQL SELECT.

This is quite a good project as you can start simple but there are a lot of options to explore.

1

u/SatanCanPutItInMyAss Sep 07 '26

oooooh ok this is pretty handy advice, thank you!