Wip: CSV import - #650
Conversation
| imdbId: item.imdbid ? item.imdbid : undefined, | ||
| tvdbId: item.tvdbid ? item.tvdbid : undefined, | ||
| rating: item.rating, | ||
| ratedAt: dateNow, |
There was a problem hiding this comment.
either use the date provided by the user, or do not set date at all
| tmdbId: item.tmdbid ? item.tmdbid : undefined, | ||
| imdbId: item.imdbid ? item.imdbid : undefined, | ||
| tvdbId: item.tvdbid ? item.tvdbid : undefined, | ||
| seenAt: dateNow, |
There was a problem hiding this comment.
either use the date provided by the user, or do not set date at all
| .filter((item) => item.rating && item.rating > 0) | ||
| .map((item) => (<ImportRatingItem>{ | ||
| itemType: item.type, | ||
| tmdbId: item.tmdbid ? item.tmdbid : undefined, |
There was a problem hiding this comment.
0 is falsy in JavaScript, and in this very rare case, 0 would be overwritten by undefined.
tmdbId can be null or undefined so passing it without any checks is the fastest option.
There was a problem hiding this comment.
I had considered this, but a tmdbId value of 0 is invalid anyway, so ending up with undefined ensures no bodgy data is passed any further down the line to be queried against the TMDB API or stored in the database. In that case, it might even be better to explicitly fail the whole import on parsing errors where no (valid) ids are found for a given row, but that might be overkill 🙂
Querying tmdb api for a movie id of "0" returns a 404 with:
{ "success": false, "status_code": 6, "status_message": "Invalid id: The pre-requisite id is invalid or not found." }
| tvdbId: item.tvdbid ? item.tvdbid : undefined, | ||
| seenAt: dateNow, | ||
| episode: item.type === 'tv' ? { | ||
| seasonNumber: item.season ? item.season : undefined, |
There was a problem hiding this comment.
if item.season is 0 (special seasons), then this will be undefined
There was a problem hiding this comment.
Ahh yep, dang it, I missed that one 🤦♂️
| name: list.name, | ||
| description: list.description, | ||
| traktId: list.traktId, | ||
| createdAt: dateNow, |
There was a problem hiding this comment.
either use the date provided by the user, or do not set date at all
|
There are few more fields I would like to include on the CSV import: Structure of the import data is not flat, a single movie can be seen multiple times, have only one rating, it can be on a watchlist and on other lists. One option to deal with this is to have four separate import files: seen history, ratings, watchlist, and lists |
|
Ahhh, sorry yep, that one wasn't supposed to land here. Just started trying to use Github desktop and mixed up my origin/upstream branches. Might just close this PR and do a new one with the right commits, make it cleaner.
Re the comments tho, My though on how to deal with this was simply to include the same movie on multiple rows. For example, the same imdbId on 4 rows with 4 different list names/ids would just add that same mediaItem to each list. This shouldn't have much impact except an extra db round trip. .
As for the various So movie tt1234567 would end up with three |
This PR adds in a CSV import mechanism to complement restoring from a backup and also to simplify switching from other system(s). Given it's such a universal input type, and nearly anything can be converted into it, this feels like a good option to have. Personally, this is helps me convert from a few separate things into one local, self-managed system, non-reliant on any large megacorp owned website that may or may not decide to completely ruin theirs (eg: 1).
The functionality extends the existing import processes, so similarly provides a progress indicator and a summary report at the end. I've put in several sanity and validation checks, so it should be reasonably safe to use to import data.
It only (currently) supports importing tv and movie items. I'll look at extending it to games, books & audiobooks as well, and I'd like to add in an export function as well. Feature wise, this lets you add items to Lists, Watchlist, Ratings and Seen history. There is some basic documentation on the csv import page in a click-to-expand.
Ignore the "Resolve pg errors on orderby in count(*)" commit, it doesn't change anything, because I'd already done a fix in my local before the sort/filter queries were re-written in b969d42.
Also solves #567