r/Python • • Aug 17 '26

Discussion What are some Python automations you built for your life?

What Python scripts/projects did you built to use on a day to day basis? Or maybe someone else built it, but it’s useful for your personal life in some way

I think the “projects ideas” thread is really missing those useful opportunities

I myself thought about automating tax calculations, but still didn’t take the time to do it hah

323 Upvotes

164 comments sorted by

View all comments

3

u/Novero95 Aug 17 '26

For media collections it's a good practice to not have the media library in the same directory as the downloads and use hardlinks to make files appear both in the library and download directories. For a single file it's easy to hardlinks it, just `ln /path/to/source_file /path/to/target_file' but for series with more than 19 episodes it quickly becomes tedious so I made a script that not only hardlinks the contents of a directory into a different one, it also checks names and rename them if needed for better compatibility with the Plex agent.

I know radarr/sonarr exist, have used them, but sonarr doesn't care that much about subtitles and the main thing I consume is anime so subtitles are a must for me. I ended up tired of sonarr deleting episodes I was happy with (that include proper subtitles) because a "better" version of the same episode had appeared, which usually didn't include subtitles in my language. It rarely takes me more than a few minutes to find whatever I want and I was handpicking episodes from the Sonarr GUI anyway so I don't feel like I need it now that my script handles hardlinking.

1

u/moreanswers Aug 17 '26

You keep all of your media in one directory, and hard-link it to a different directory? I'm not sure what the benefit is?

Do you do that so you can have different libraries for different apps backed by the same files?

1

u/Novero95 Aug 17 '26

Yes. I follow that approach since I set up sonarr/radarr following the "Trash Guides" pages which is usually recommended when people talk about Sonarr/Radarr set up. I'm not sure of the exact reason they did it like this but Sonarr/Radarr are designed to work this way and they handle hardlinking automatically. I think one of the reasons may be security since there are people with open ports to Plex/Jellyfin.

But as I said I don't use Sonarr and Radarr anymore, they reason I still adhere to that layout is that my media library is well organized so having different folders for media and downloads allows me to freely move and rename stuff in the library folder so it follows proper Plex naming and organization and, at the same time, things stay in the downloads folder just as they were downloaded so qBitTorrent doesn't lose track of the files being seeded. An example of this, an anime film that is a continuation of an anime series can be downloaded independently of the series and then put in the /Specials directory inside the anime directory with the proper S00Exx denomination from TheTVDB and, at the same time, I can hardlink it into the movies directory with a different name for TheMovieDB so the same film will be available both in TV series/anime_name/specials and movies. Or just so I can rename things that are downloaded with weird names and 00-to_infinite episode numbering (typical in long animes for some reason) instead of SxxExx. As you said, having different libraries for different agents could be done but I have not had problems between agents so I don't find it necessary. As you see, much of it boils down to I can move/rename stuff and seed it at the same time, and because I'm used to it from when I was using Radarr/Sonarr.

I guess I could tinker with permissions too but I don't care a lot about it since I don't expose services. I don't know if there are other advantages I haven't thought about.

1

u/moreanswers Aug 17 '26

I keep my seedbox data and my NAS completely separated (just because it's hosted at a different location), so I never thought about hard-linking the data so that I can seed and keep it in my library at the same time, that's smart.

1

u/Novero95 Aug 18 '26

So you basically have two copies of everything? My media library is confined to a single 1TB HDD, around 90GB are free right now so not like I can waste space.

1

u/moreanswers Aug 18 '26

I have a lot of drive space, mostly purchased over the last 8-10 years. The seed box has 4x4tb drives raidz1, and my NAS has 16x2tb, 8x8tb 3.5", and 4x4tb.

2

u/Novero95 Aug 18 '26

That seems like a good amount of storage, but given current prices... it would cost a small fortune. I have a 2x4TB mirrored pool where I keep the important stuff but I decided that media wasn't relevant enough to be in the only drives whose content I actually care about so it's limited to the savaged 1TB HDD. It works for me though, I don't really plan to build a huge media library so I will delete stuff if I'm running out of storage

2

u/moreanswers Aug 18 '26

I don't envy anyone getting into home data storage the last 18 months. The prices are insane.