xbmc / Official-Kodi-Remote-iOS

Full-featured remote control for XBMC Media Center. It features library browsing, now playing informations and a direct remote control.
Other
221 stars 104 forks source link

We have a genre view; what about a tag view? #1106

Closed gavinstevenson closed 1 month ago

gavinstevenson commented 2 months ago

First off, great app. Of all the iOS-compatible Kodi remotes, I think this one is the best.

Feature Request

Jumping right into the feature request, would you be open to adding a "Tag" view to the app?

In the "Movies" main menu item, there are several icons on the bottom right that change the right panel's view when pressed. These are "Movies", "Genres", "Movie Sets" and "Recently Added" followed by a "..." for all other views.

While the "Genres" view is useful when the user just wants to watch any action or comedy movie, it lacks granularity. What if the user wants to watch a mafia movie? A WWII movie? A movie about the sea? Genres aren't this specific, but the tags on IMDB and TMDB can get extremely precise and when they're scraped into a user's library, they offer an extremely useful way to quickly find the perfect film for movie night.

Implementation Details

As I understand it, the way the app currently gets library info from Kodi is by issuing the following JSON query:

[root@basementhtp ~]$ curl --data-binary '{"jsonrpc":"2.0","method":"VideoLibrary.GetMovieDetails","params":{"movieid":3,"properties":["year","playcount","rating","thumbnail","genre","runtime","studio","director","plot","mpaa","votes","cast","file","fanart","resume","trailer","dateadded","tagline","art"]},"id":2}' -H 'content-type: application/json;' http://basementhtpc:8080/jsonrpc | python3 -m json.tool

If "tag" was added as an additional property to the above query list, Kodi will dutifully supply all the tags associated with the relevant movieid.

But then where should we expose those tags in the UI of the App? I can see two natural locations: the first would be on each movie's info pane. Right under the "genres" section would work, but since tags are often more numerous/plentiful than genres (it's not uncommon for movies to have 3-6 tags while only 1-2 genres), I could also understand wanting to put them closer to the bottom, right after the rating for design/layout reasons. Please see here for a screenshot.

But knowing what specific tags a movie has is only half the battle. How do we help a user quickly scroll through all the tags in their library in much the same way they can scroll through all the genres in their library?

A Tag view, implemented in exactly the same way we have a Genre view, would be very useful. Please see here for a screenshot.

Useful Resources

In the spirit of trying to be as helpful as possible, here are some additional links/resources that you might find useful:

Here's a properly formatted/compliant .NFO of the same movie from TMDB containing "tag" tags (they're enumerated near the top, right under the "genre" tags):

[root@basementhtpc ~]$ cat /mnt/video/movies_test/ANALYZE_THIS_\(1999\)_\(DVD\)/ANALYZE_THIS.nfo 
<?xml version='1.0' encoding='UTF-8' standalone='yes'?>
<movie>
    <title>Analyze This</title>
    <userrating>0</userrating>
    <top250>0</top250>
    <outline>Countless wiseguy films are spoofed in this film that centers on the neuroses and angst of a powerful Mafia racketeer who suffers from panic attacks. When Paul Vitti needs help dealing with his role in the "family," unlucky shrink Dr. Ben Sobel is given just days to resolve Vitti's emotional crisis and turn him into a happy, well-adjusted gangster.</outline>
    <plot>Countless wiseguy films are spoofed in this film that centers on the neuroses and angst of a powerful Mafia racketeer who suffers from panic attacks. When Paul Vitti needs help dealing with his role in the "family," unlucky shrink Dr. Ben Sobel is given just days to resolve Vitti's emotional crisis and turn him into a happy, well-adjusted gangster.</plot>
    <tagline>New York's most powerful gangster is about to get in touch with his feelings. YOU try telling him his 50 minutes are up.</tagline>
    <runtime>103</runtime>
    <mpaa>R</mpaa>
    <playcount>0</playcount>
    <lastplayed></lastplayed>
    <id>tt0122933</id>
    <premiered>1999-03-05</premiered>
    <year>1999</year>
    <!-- <trailer>https://www.youtube.com/watch?v=ejjjWYYST1Q</trailer> -->
    <!-- <trailer>/mnt/video/movies_test/ANALYZE_THIS_(1999)_(DVD)/ANALYZE_THIS-trailer.mkv</trailer> -->
    <trailer>https://www.youtube.com/watch?v=2ZrWHtvSog4</trailer>
    <dateadded>2006-12-19 10:37:45</dateadded>
    <ratings>
        <rating max="10" name="themoviedb" default="true">
            <value>6.483</value>
            <votes>1804</votes>
        </rating>
    </ratings>
    <thumb preview="http://image.tmdb.org/t/p/w342/eqa4TEgkx63WRhqyD8eTwmL7bUi.jpg" aspect="poster">http://image.tmdb.org/t/p/original/eqa4TEgkx63WRhqyD8eTwmL7bUi.jpg</thumb>
    <thumb preview="http://image.tmdb.org/t/p/w342/15yjlhuFI290wpT3gvMx8ooXwNV.jpg" aspect="poster">http://image.tmdb.org/t/p/original/15yjlhuFI290wpT3gvMx8ooXwNV.jpg</thumb>
    <thumb preview="http://image.tmdb.org/t/p/w342/dEmymWoXVZnD5Busuo7LaoICz9S.jpg" aspect="poster">http://image.tmdb.org/t/p/original/dEmymWoXVZnD5Busuo7LaoICz9S.jpg</thumb>
    <thumb preview="http://image.tmdb.org/t/p/w342/78EYFmm5J6apB1eGqvl08PMT1Cp.jpg" aspect="poster">http://image.tmdb.org/t/p/original/78EYFmm5J6apB1eGqvl08PMT1Cp.jpg</thumb>
    <fanart>
        <thumb preview="http://image.tmdb.org/t/p/w780/vQIfm267TN8Er0xTy6QnLcBGr5v.jpg">http://image.tmdb.org/t/p/original/vQIfm267TN8Er0xTy6QnLcBGr5v.jpg</thumb>
        <thumb preview="http://image.tmdb.org/t/p/w780/wX1p8j5cRlMVXI4QyxT7WmZzKwI.jpg">http://image.tmdb.org/t/p/original/wX1p8j5cRlMVXI4QyxT7WmZzKwI.jpg</thumb>
        <thumb preview="http://image.tmdb.org/t/p/w780/oas0DvvhhaMncvn805LjepxeoZh.jpg">http://image.tmdb.org/t/p/original/oas0DvvhhaMncvn805LjepxeoZh.jpg</thumb>
        <thumb preview="http://image.tmdb.org/t/p/w780/k8V1VfebAwSSNrDypupZ22eLT6U.jpg">http://image.tmdb.org/t/p/original/k8V1VfebAwSSNrDypupZ22eLT6U.jpg</thumb>
    </fanart>
    <uniqueid type="imdb" default="true">tt0122933</uniqueid>
    <uniqueid type="tmdb">9535</uniqueid>
    <genre>Comedy</genre>
    <genre>Crime</genre>
    <tag>new york city</tag>
    <tag>mafia</tag>
    <tag>wedding</tag>
    <country>Australia</country>
    <country>United States of America</country>
    <set>
        <name>Analyze Collection</name>
        <overview>A series about a mob boss Paul Vitti and his relationship with his psychiatrist Dr. Ben Sobel.</overview>
    </set>
    <credits>Harold Ramis</credits>
    <credits>Peter Tolan</credits>
    <credits>Kenneth Lonergan</credits>
    <director>Harold Ramis</director>
    <studio>Spring Creek Productions</studio>
    <studio>Tribeca Productions</studio>
    <studio>Baltimore Pictures</studio>
    <studio>Warner Bros. Pictures</studio>
    <actor>
        <name>Robert De Niro</name>
        <role>Paul Vitti</role>
        <order>0</order>
        <thumb>/mnt/video/movies/ANALYZE_THIS_(1999)_(DVD)/.actors/Robert_De_Niro.jpg</thumb>
        <!-- <thumb>http://image.tmdb.org/t/p/original/cT8htcckIuyI1Lqwt1CvD02ynTh.jpg</thumb> -->
    </actor>
    <actor>
        <name>Billy Crystal</name>
        <role>Dr. Ben Sobel</role>
        <order>1</order>
        <thumb>/mnt/video/movies/ANALYZE_THIS_(1999)_(DVD)/.actors/Billy_Crystal.jpg</thumb>
        <!-- <thumb>http://image.tmdb.org/t/p/original/nLVT3OFx58ePsESSBJ9XWCMq28d.jpg</thumb> -->
    </actor>
    <actor>
        <name>Lisa Kudrow</name>
        <role>Laura MacNamara Sobel</role>
        <order>2</order>
        <thumb>/mnt/video/movies/ANALYZE_THIS_(1999)_(DVD)/.actors/Lisa_Kudrow.jpg</thumb>
        <!-- <thumb>http://image.tmdb.org/t/p/original/9YNzHuT7L0wdEl3zua6iUYz5tYT.jpg</thumb> -->
    </actor>
    <actor>
        <name>Chazz Palminteri</name>
        <role>Primo Sidone</role>
        <order>3</order>
        <thumb>/mnt/video/movies/ANALYZE_THIS_(1999)_(DVD)/.actors/Chazz_Palminteri.jpg</thumb>
        <!-- <thumb>http://image.tmdb.org/t/p/original/A3e7IRkWkChHNn4p6riRR8Kd6g0.jpg</thumb> -->
    </actor>
    <actor>
        <name>Joe Viterelli</name>
        <role>Jelly</role>
        <order>4</order>
        <thumb>/mnt/video/movies/ANALYZE_THIS_(1999)_(DVD)/.actors/Joe_Viterelli.jpg</thumb>
        <!-- <thumb>http://image.tmdb.org/t/p/original/tGXum13Ec5Uigw7myg4qcU9wahy.jpg</thumb> -->
    </actor>
    <actor>
        <name>Molly Shannon</name>
        <role>Caroline</role>
        <order>5</order>
        <thumb>/mnt/video/movies/ANALYZE_THIS_(1999)_(DVD)/.actors/Molly_Shannon.jpg</thumb>
        <!-- <thumb>http://image.tmdb.org/t/p/original/gFuqGF0IO4e9IjiJYAvGI9205Sq.jpg</thumb> -->
    </actor>
    <actor>
        <name>Kresh Novakovic</name>
        <role>'50s Gangster</role>
        <order>6</order>
        <thumb>/mnt/video/movies/ANALYZE_THIS_(1999)_(DVD)/.actors/Kresh_Novakovic.jpg</thumb>
        <!-- <thumb>http://image.tmdb.org/t/p/original/jKWZ3512cBBg95wStOPR8nPbm1j.jpg</thumb> -->
    </actor>
    <actor>
        <name>Bart Tangredi</name>
        <role>Young Vitti Sr.</role>
        <order>7</order>
        <thumb>/mnt/video/movies/ANALYZE_THIS_(1999)_(DVD)/.actors/Bart_Tangredi.jpg</thumb>
        <!-- <thumb>http://image.tmdb.org/t/p/original/djtWzneCdjgPQ3zJeb7Ub2FYh6p.jpg</thumb> -->
    </actor>
    <actor>
        <name>Michael Straka</name>
        <role>Young Dominic Manetta</role>
        <order>8</order>
        <thumb>/mnt/video/movies/ANALYZE_THIS_(1999)_(DVD)/.actors/Michael_Straka.jpg</thumb>
        <!-- <thumb></thumb> -->
    </actor>
    <actor>
        <name>Kyle Sabihy</name>
        <role>Michael Sobel</role>
        <order>9</order>
    </actor>
    <actor>
        <name>Frank Pietrangolare</name>
        <role>Tuna</role>
        <order>10</order>
        <thumb>/mnt/video/movies/ANALYZE_THIS_(1999)_(DVD)/.actors/Frank_Pietrangolare.jpg</thumb>
        <!-- <thumb>http://image.tmdb.org/t/p/original/wFohY73v2kG0HuoLWsq0ORgMkph.jpg</thumb> -->
    </actor>
    <actor>
        <name>Ron Madoff</name>
        <role>Extra Sea World Scene</role>
        <order>11</order>
    </actor>
    <actor>
        <name>Leo Rossi</name>
        <role>Carlo Mangano</role>
        <order>12</order>
        <thumb>/mnt/video/movies/ANALYZE_THIS_(1999)_(DVD)/.actors/Leo_Rossi.jpg</thumb>
        <!-- <thumb>http://image.tmdb.org/t/p/original/j18Nva8OAFwQrIvkfQHUF98SZFl.jpg</thumb> -->
    </actor>
    <actor>
        <name>Donna Marie Recco</name>
        <role>Sheila</role>
        <order>13</order>
        <thumb>/mnt/video/movies/ANALYZE_THIS_(1999)_(DVD)/.actors/Donna_Marie_Recco.jpg</thumb>
        <!-- <thumb>http://image.tmdb.org/t/p/original/rRDRcavGxUNTXoxWR6zI8tp80Mx.jpg</thumb> -->
    </actor>
    <actor>
        <name>Joseph Rigano</name>
        <role>Dominic Manetta</role>
        <order>14</order>
    </actor>
    <actor>
        <name>Max Casella</name>
        <role>Nicky Shivers</role>
        <order>15</order>
        <thumb>/mnt/video/movies/ANALYZE_THIS_(1999)_(DVD)/.actors/Max_Casella.jpg</thumb>
        <!-- <thumb>http://image.tmdb.org/t/p/original/5CNTDSCBhWPclTLTyTBy8oHUkzb.jpg</thumb> -->
    </actor>
    <actor>
        <name>Bill Macy</name>
        <role>Dr. Isaac Sobel</role>
        <order>16</order>
        <thumb>/mnt/video/movies/ANALYZE_THIS_(1999)_(DVD)/.actors/Bill_Macy.jpg</thumb>
        <!-- <thumb>http://image.tmdb.org/t/p/original/gs6oJkNvogz8mr1azGiPBNY0yyw.jpg</thumb> -->
    </actor>
    <actor>
        <name>Jimmie Ray Weeks</name>
        <role>FBI Agent Steadman</role>
        <order>17</order>
    </actor>
    <actor>
        <name>Tony Darrow</name>
        <role>Moony</role>
        <order>18</order>
        <thumb>/mnt/video/movies/ANALYZE_THIS_(1999)_(DVD)/.actors/Tony_Darrow.jpg</thumb>
        <!-- <thumb>http://image.tmdb.org/t/p/original/kc6cGKm2yYx5ekHo4zGizhMLBge.jpg</thumb> -->
    </actor>
    <actor>
        <name>Gene Ruffini</name>
        <role>Frankie Zello</role>
        <order>19</order>
    </actor>
    <actor>
        <name>Richard C. Castellano</name>
        <role>Jimmy Boots</role>
        <order>20</order>
    </actor>
    <actor>
        <name>Frank Aquilino</name>
        <role>Eddie 'Cokes'</role>
        <order>21</order>
        <thumb>/mnt/video/movies/ANALYZE_THIS_(1999)_(DVD)/.actors/Frank_Aquilino.jpg</thumb>
        <!-- <thumb>http://image.tmdb.org/t/p/original/zAwaElGYFiVXXnmj7h1KyjMMTd5.jpg</thumb> -->
    </actor>
    <resume>
        <position>0</position>
        <total>0</total>
    </resume>
</movie>

Here's what a successful result looks like when querying Kodi via the JSON API for the above .NFO. Note the tags returned as a set of strings in the middle of the excerpt below:

[root@basementhtpc ~]$ curl --data-binary '{"jsonrpc":"2.0","method":"VideoLibrary.GetMovieDetails","params":{"movieid":3,"properties":["tag","year","playcount","rating","thumbnail","genre","runtime","studio","director","plot","mpaa","votes","cast","file","fanart","resume","trailer","dateadded","tagline","art"]},"id":2}' -H 'content-type: application/json;' http://basementhtpc:8080/jsonrpc | python3 -m json.tool
{
    "id": 2,
    "jsonrpc": "2.0",
    "result": {
        "moviedetails": {
 [ -------- SNIP FOR BREVITY ------- ]
            "runtime": 6180,
            "studio": [
                "Spring Creek Productions",
                "Tribeca Productions",
                "Baltimore Pictures",
                "Warner Bros. Pictures"
            ],
            "tag": [
                "new york city",
                "mafia",
                "wedding"
            ],
            "tagline": "New York's most powerful gangster is about to get in touch with his feelings. YOU try telling him his 50 minutes are up.",
            "thumbnail": "",
            "trailer": "https://www.youtube.com/watch?v=2ZrWHtvSog4",
            "votes": "1804",
            "year": 1999
        }
    }
}
wutschel commented 2 months ago

Thanks for feedback and the suggestion. From a UI perspective I can imagine to go for a 2nd press of the gerne toolbar icon to toggle between genre and tag view. Similar functions are implemented for the movies toolbar icon which toggles through all > unwatched > watched movies. But sadly this cannot be implemented straight forward as this is not in line with how the app logic is organized. It would be easy to add "tag" when synchronizing movies (increasing also the sync time) and allow searching for "tag" in Global Search. This is only a few lines of code. Alternatively I can imagine to create a new submenu, like for genres, selectable after entering "...". But this more complicated as the API does have a "GetTags" method and the whole processing must be implemented only for this very functionality.

wutschel commented 2 months ago

Oh, need to correct myself -- there is VideoLibrary.GetTags". This needs more work, but here is a first impression:

Simulator-Screenshot-i-Phone-14-Pro-2024-08-14-at-21-42-19 Simulator-Screenshot-i-Phone-14-Pro-2024-08-14-at-21-59-02

gavinstevenson commented 2 months ago

Awesome, appreciate the quick response. A few thoughts about what you've written:

On implementing a "Tab" view as a 2nd tap option for the Genre toolbar icon

Implementing a Tags view as a 2nd press of the Genre toolbar icon is interesting. I actually did not know it was possible to press those toolbar icons multiple times to change what's displayed! If the app logic wouldn't easily allow for this, I think that should guide our efforts elsewhere in the code. Plus, I think discoverability would suffer. It's not immediately obvious to the user that they have the option to press those toolbars multiple times to change views, and while once someone figures it out, they'll know, I imagine most users won't figure that out. I also suspect that a user who taps the Genres view might be surprised to suddenly see that switch to Tags. Feels like we'll want to keep the Principle of Least Surprise in mind.

On adding the tags to the Global Search during a sync

This sounds like an excellent idea, especially if it's only a few lines of code. Having a list of them like what's included in the Genre view would be ideal for discoverability since you may not know what tag to search for in the first place (they can be as specific/precise as the users of IMDB and TMDB make them), but making them globally searchable is a great first step forward and one worth doing, in my opinion.

On creating a new submenu for Tags under the "..."

This sounds like the ideal solution, but I can understand the reluctance around the processing/building the data structures necessary to keep track of the tag data as a library is scraped. As a long-time embedded firmware/software engineer, I'm far less familiar with iOS development and this specific code base but would it be possible, as part of the sync process, to pass each JSON result to a function that looks only at the tag values and movie names and use those to construct a directed acyclic word graph (see below for links) that is then searchable for the Tags view?

Useful links: https://jbp.dev/blog/dawg-basics.html https://stackoverflow.com/questions/19254696/best-way-to-construct-a-directed-acyclic-word-graph-dawg https://en.wikipedia.org/wiki/Deterministic_acyclic_finite_state_automaton https://github.com/vtortola/dawg

gavinstevenson commented 2 months ago

Oh whoa! Hold on - I'm just seeing your updates on VideoLibrary.GetTags!

Yes! This is exactly it! That would be so useful to have!

wutschel commented 2 months ago

Yes, was also surprised to see this already being available. I can add this to the menu structure under the "...". Still quite some work to do it right, but straight forward. I will put this in my backlog. There are some other changes which want to get mainlines first, especially as they also change the menu code.

I am a bit worried about the index overlap with the indicator. Index is for sure needed, I already 500+ tags for about 40 movies in my test database. The index layout always has been a bit tricky, let's see.

gavinstevenson commented 2 months ago

Understood. If there's anything I can do to support/accelerate, let me know. I don't think I have the proper development environment for iOS (I have Debian 12 workstation, a RHEL 9.x server, and an iPad) but if there's some way I can be useful, I'd be happy to help.

When you say you're "a bit worried about the index overlap with the indicator", could you share more about that? (I don't know what those terms mean in this context.)

I can attest to the fact that it's normal to see that many tags. In practice, they don't scale linearly with the size of a library (i.e., the more movies you have, the tag count starts to slow dramatically given how many overlap), but it's not uncommon to see 1200-1500 for medium to large libraries.

For those who curate their libraries, I'll often remove tags I think are superfluous/too niche using the media managers I use to wrangle my library.

wutschel commented 2 months ago

The index is the blue vertical set of characters that be used to quickly navigation to the sections which are grouped first character of the tag, e.g. "1" for "1930s", "1940s" and such. The indicator is the right arrow at the right end of each row which indicates there's a next level of information when clicking on the row.

Thanks for your explanation on non-linear growth which makes perfect sense. The more movies you have, the more often they use same tags and group up under them.

And thanks form offering support. I might post questions here, if they arise. In best case I will ask you for testing a TestFlight build when it was made available. Expect this to take some weeks from here, due to other work going first and due to real life.😉

gavinstevenson commented 2 months ago

Ah, I see, ok thanks for the context on "index" and "indicator." Makes perfect sense now.

Regarding the timing, I definitely understand. This is a side project for all of us and I can easily imagine there are higher priority tasks that may already be in the pipeline (plus, just general life). Happy to sit tight, continue monitoring, and remain patient!