Commit Graph

506 Commits

Author SHA1 Message Date
zurdi
c6039ccff4 fix: correct filter condition for retrieving collections associated with a ROM ID 2024-12-05 16:16:34 +00:00
zurdi
014427e69f fix: update ROM deletion process to remove associated collections and streamline user data updates 2024-12-05 16:08:45 +00:00
zurdi
eae8d34d8f fix: convert zlib error to string for better logging in ROM hash calculation 2024-12-04 00:10:44 +00:00
zurdi
7614df07b1 fix: handle zlib error when calculating ROM hashes for corrupted files 2024-12-04 00:06:06 +00:00
Zurdi
a6ff9baf80 Merge pull request #1324 from rommapp/feature/add-platform-info
feat: Add platform info drawer + per platform settings
2024-12-03 19:01:16 +01:00
Zurdi
5b39127a02 Merge pull request #1323 from rommapp/fix/check-user-on-middleware
fix: Crash on new instance from previous installation
2024-12-03 00:25:42 +01:00
Zurdi
219145e000 Update middleware based on review 2024-12-02 18:56:58 +01:00
zurdi
caa24433b1 refactor: improve user authentication handling without requesting to database 2024-12-02 15:37:13 +00:00
zurdi
44afc718a6 refactor: check user existence only for /api/heartbeat endpoint 2024-12-02 15:09:36 +00:00
zurdi
52ccd1c727 fixes based on unit testing 2024-12-02 11:20:40 +00:00
Michael Manganiello
0a4c81d5c1 misc: Retrieve roms by filename from database in bulk during scan
The scanning process could try to fetch thousands of roms from the
database, one by one, which is very inefficient, especially when only a
few new roms are added to the library, as the overhead of database calls
is very high compared to metadata API calls.

This change introduces a new method in the roms handler to retrieve roms
by their file names in bulk, which is used during the scan process to
fetch a batch of roms at once, instead of one by one.

It also avoids the `@with_details` decorator when fetching roms during
the scanning process, as those details are not needed, and they were
adding unnecessary joins and data decoding.
2024-12-02 00:00:47 -03:00
zurdi
6a7433e1f9 removed unnecessary video endpoint request 2024-11-28 16:12:05 +00:00
zurdi
cb5d2438d2 Merge remote-tracking branch 'origin/master' into feature/add-platform-info 2024-11-28 15:23:32 +00:00
zurdi
a29a14aefb normalized covers and logos 2024-11-28 15:23:20 +00:00
zurdi
bf41d9ff05 fixed total crash on a fresh installation having session cookies from previous installation 2024-11-28 12:30:13 +00:00
zurdi
be87d92cf7 fixed platform info migration and models 2024-11-28 12:28:29 +00:00
zurdi
06e524f650 Merge branch 'master' into feature/add-platform-info 2024-11-27 22:51:16 +00:00
zurdi
213e62b31b added mask to mobygames api 2024-11-27 17:29:10 +00:00
zurdi
a51dd03e1a Added full offline support and configurable logging level and API requests debug logs 2024-11-27 17:12:13 +00:00
zurdi
80b7cc7333 added basic platform info from the igdb api call 2024-11-27 11:43:06 +00:00
Michael Manganiello
4ecbac73b3 Merge pull request #1300 from rommapp/fix/igdb-game-search-categories
fix: Consider more categories when matching IGDB games
2024-11-17 01:46:23 -03:00
Michael Manganiello
71ac92bfb6 fix: Consider IGDB alternatives when checking for exact match
IGDB provides alternative names for games, which we are currently not
considering when checking for an exact match.

This change starts considering alternative names, in addition to the
game's name and slug, when checking for an exact match.
2024-11-16 20:58:20 -03:00
Michael Manganiello
deaac348da fix: Consider more categories when matching IGDB games
This change includes more categories when matching IGDB games. While
testing, some games were incorrectly matched to the wrong game, and the
reason was that the game was a Port (e.g. `Arkanoid`, `Contra`,
`Double Dragon`, `Metal Gear` for NES), a Remake (e.g.
`Adventure Island` for NES), or a Remaster.
2024-11-16 20:44:41 -03:00
Michael Manganiello
477d9b1744 feat: Add streaming support for 7zip hashing
At the moment, 7zip files are generating memory issues and even OOM
errors on user installations. This is because the current stable release
of `py7zr` does not support decompression streaming, and RomM needs to
decompress the each 7zip file in the library into memory to be able to
calculate hashes.

This change introduces a `py7zr` fork I created to have a stable commit
SHA to refer to in case upstream gets any forced pushes. It includes the
contents of the pull request the `py7zr` creator is working on to
support decompression streaming [1].

The way decompression streaming is implemented in `py7zr` is different
than the other compression utilities. Instead of being able to provide a
`bytes` iterator, we need to provide a `Py7zIO` implementation that
will call a callback on each read and write operation.

[1] https://github.com/miurahr/py7zr/pull/620
2024-11-08 21:31:11 -03:00
Michael Manganiello
009a436915 Merge pull request #1265 from rommapp/misc/initial-igdb-typehints
misc: Initial addition of IGDB typehints
2024-10-29 13:23:02 -03:00
Michael Manganiello
6410b6b981 Merge pull request #1263 from rommapp/fix/download-igdb-screenshot-right-aspect-ratio
fix: Download IGDB screenshots with right aspect ratio
2024-10-29 13:22:36 -03:00
Michael Manganiello
2ff37f268d Merge pull request #1261 from rommapp/fix/broken-igdb-age-rating-image-links
fix: Broken IGDB age rating image links
2024-10-29 13:22:25 -03:00
Michael Manganiello
4bb5cb5149 misc: Initial addition of IGDB typehints
The short-term goal is to completely typehint the IGDB API responses. This
first change adds the base structures and enums RomM currently uses.

The `ExpandableField` type will allow us to model the expansion
mechanism the IGDB API provides, where a field can include either an ID,
or the full nested structure.
2024-10-27 00:02:01 -03:00
Michael Manganiello
752096451e fix: Download IGDB screenshots with right aspect ratio
The IGDB API provides screenshots in a 1280x720 resolution, when either
`screenshot_huge` or `720p` size values are used [1]. The
`screenshot_huge` uses `Lfill`, while `720p` uses `Fit` as the resizing
method.

That means that either `screenshot_huge` or `720p` will provide the
correct aspect ratio for 16:9 platforms. However, for platforms with a
different aspect ratio, we need to use the `720p` size value to get the
correct image instead of a cropped one.

Example:
- [`screenshot_huge`](https://images.igdb.com/igdb/image/upload/t_screenshot_huge/c77bodnkwu73gs2jwhw4.jpg)
- [`720p`](https://images.igdb.com/igdb/image/upload/t_720p/c77bodnkwu73gs2jwhw4.jpg)

[1] https://api-docs.igdb.com/#images
2024-10-26 18:26:00 -03:00
Michael Manganiello
0190566530 fix: Broken IGDB age rating image links
Some of the image links for IGDB age ratings were broken. This commit
fixes all of them.
2024-10-26 01:19:57 -03:00
Michael Manganiello
8fd680ab84 fix: Make tar decompression only consider regular files
The `tar` decompression function was failing for some users, with error
message:

```
'NoneType' object does not support the context manager protocol
```

As explained in the official documentation [1], the `extractfile` method
returns `None` if the member is not a regular file or a link. This
change skips any member that is not a regular file.

[1] https://docs.python.org/3/library/tarfile.html#tarfile.TarFile.extractfile
2024-10-26 01:07:27 -03:00
Michael Manganiello
beeb9f0c31 misc: Create enum for authorization scopes
Instead of using just strings, this change converts the scopes to a
`StrEnum`, to be compatible with places where a string is expected. This
avoids typos when using these scopes, simplifies searching for usages,
and improves type hints.

An extra change was the fix to the Firmware download endpoint, which
wasn't respecting the `DISABLE_DOWNLOAD_ENDPOINT_AUTH` flag.
2024-10-18 23:57:42 -03:00
Michael Manganiello
eba2971ffb fix: Simplify query that validates new username already exists
Instead of fetching all users and checking if the new username is present
in the list, we can directly query the database for the username.
2024-10-14 01:10:31 -03:00
Georges-Antoine Assi
72182b9f22 Merge pull request #1240 from alisci01/add-offset-to-get-roms-endpoint
Add offset parameter to get_roms endpoint
2024-10-13 22:31:14 -04:00
Michael Manganiello
a594eff413 Merge pull request #1238 from rommapp/fix-save-small-artworks
fix: Correctly resize and save small artwork
2024-10-12 13:34:30 -03:00
Ali Scissons
5acbdfdf8b add offset parameter to get_roms endpoint 2024-10-11 23:28:30 -05:00
Michael Manganiello
a9ac322618 fix: Correctly resize and save small artwork
The previous implementation was calling `resize_cover_to_small` within
the context manager that was writing the image to the filesystem. This
was causing `PIL` to raise an error because it could not identify the
open and temporarily created file as a valid image.

Instead of saving the original image to the filesystem and then resizing
it, we now open the image in memory, resize it, and then save it to the
filesystem. We also avoid reading the `BytesIO` object twice by saving
small and big images from the same initial `Image` object.

Fixes #1191.
2024-10-12 00:55:06 -03:00
Michael Manganiello
b81fbc5820 fix: Improve handling of Redis URL
This change replaces the creation of Redis URL, from a simple string
interpolation, to using `yarl.URL`. The main benefit, besides not
forgetting to set all five different variables on every Redis client
initialization, is that user credentials are correctly URL-encoded, if
present.

Up until now, if a password had special characters, it could break the
generated URL.

This change also introduces support for a `REDIS_SSL` setting, which
allows the user to specify if the Redis connection should use SSL or not.
2024-10-11 21:41:19 -03:00
Michael Manganiello
149098fb31 fix: Improve memory usage during 7zip decompression
This change improves memory usage, by only keeping a single archive's
member file in memory at a time during 7zip decompression.

The `py7zr` library does not support streaming decompression yet, so
this change is the best we can do for now.

Potential fix for #1211, but it won't improve memory usage for
single-file 7zip archives.
2024-10-06 20:18:49 -03:00
Georges-Antoine Assi
6880d11a73 Merge branch 'master' into romm-1114 2024-09-21 12:30:39 -04:00
Georges-Antoine Assi
6cb332efcf changes from reciew 2024-09-21 12:23:23 -04:00
Georges-Antoine Assi
fc6455eccb Merge pull request #1137 from rommapp/romm-829
[ROMM-829] Status fields on rom user
2024-09-09 19:41:38 -04:00
Georges-Antoine Assi
97496d1171 Merge pull request #1184 from rommapp/romm-1176
[ROMM-1176] Fetch video ID and place in carousel
2024-09-09 10:12:46 -04:00
Georges-Antoine Assi
8fc25cde99 use timezone aware datetimes 2024-09-09 10:11:46 -04:00
Georges-Antoine Assi
fc85fcb6a9 fix pytests 2024-09-09 00:01:37 -04:00
Georges-Antoine Assi
2765a6e2c3 [ROMM-1176] Fetch video ID and place in carousel 2024-09-08 23:47:25 -04:00
Georges-Antoine Assi
4a664ab790 [ROMM-1181] Skip hashing games on desktop platorms 2024-09-08 23:08:50 -04:00
Georges-Antoine Assi
8dae0a503c add simple emojis to cards 2024-09-08 13:59:10 -04:00
Georges-Antoine Assi
e432bc32ac Merge branch 'master' into romm-1114 2024-09-03 19:13:33 -04:00
Georges-Antoine Assi
9b6b19eb27 Merge branch 'master' into romm-829 2024-09-03 18:58:06 -04:00