Project

General

Profile

Actions

Feature #1054

open

Grab genre list next to video json

Added by Hammel about 1 year ago. Updated about 1 year ago.

Status:
In Progress
Priority:
Urgent
Assignee:
Category:
Database
Target version:
Start date:
20 Oct 2023
Due date:
% Done:

10%

Estimated time:
Severity:
03 - Medium

Description

To get it, use this API
Login and click Header / Access Token for authentication credentials.

The JSON output should be stored in the videolib directory. This will allow videofe to search by genre at some point in the future.

Actions #1

Updated by Hammel about 1 year ago

  • Project changed from VideoFE to VideoLib
  • Category changed from Database to Database
Actions #2

Updated by Hammel about 1 year ago

  • Status changed from New to In Progress
  • % Done changed from 0 to 10

Here is the Java code to retrieve the genre list. It uses OkHttpClient which doesn't really fit into VideoLib easily, so I'll need to translate into "buildXXXQuery()" methods I've implemented for other queries in com/ximba/videolib/TVDB.java.

OkHttpClient client = new OkHttpClient();

Request request = new Request.Builder()
  .url("https://api.themoviedb.org/3/genre/tv/list?language=en")
  .get()
  .addHeader("accept", "application/json")
  .addHeader("Authorization", "Bearer eyJhbGciOiJIUzI1NiJ9.eyJhdWQiOiJjZjY3YWY5MzI5OTEwOGE0ODcwNzRhNTgxMWFiNDFlZCIsInN1YiI6IjRiYzg4OTM5MDE3YTNjMGY5MjAwMGM1YyIsInNjb3BlcyI6WyJhcGlfcmVhZCJdLCJ2ZXJzaW9uIjoxfQ.Vu3S0HkwcC5dHUZGMF2ErS1-jiPZdwN7CgzFq1_lFM8")
  .build();

Response response = client.newCall(request).execute();

The JSON response looks like this.

{
  "genres": [
    {
      "id": 10759,
      "name": "Action & Adventure" 
    },
    {
      "id": 16,
      "name": "Animation" 
    },
    {
      "id": 35,
      "name": "Comedy" 
    },
    {
      "id": 80,
      "name": "Crime" 
    },
    {
      "id": 99,
      "name": "Documentary" 
    },
    {
      "id": 18,
      "name": "Drama" 
    },
    {
      "id": 10751,
      "name": "Family" 
    },
    {
      "id": 10762,
      "name": "Kids" 
    },
    {
      "id": 9648,
      "name": "Mystery" 
    },
    {
      "id": 10763,
      "name": "News" 
    },
    {
      "id": 10764,
      "name": "Reality" 
    },
    {
      "id": 10765,
      "name": "Sci-Fi & Fantasy" 
    },
    {
      "id": 10766,
      "name": "Soap" 
    },
    {
      "id": 10767,
      "name": "Talk" 
    },
    {
      "id": 10768,
      "name": "War & Politics" 
    },
    {
      "id": 37,
      "name": "Western" 
    }
  ]
}

So a query for the series South Park would look like this:

http://api.themoviedb.org/3/search/tv?api_key=cf67af93299108a487074a5811ab41ed&query=South+Park

{
  "page": 1,
  "results": [
    {
      "adult": false,
      "backdrop_path": "/41neXsH222hV2zrsTyw8h7javon.jpg",
      "genre_ids": [
        16,
        35
      ],
      "id": 2190,
      "origin_country": [
        "US" 
      ],
      "original_language": "en",
      "original_name": "South Park",
      "overview": "Follows the misadventures of four irreverent grade-schoolers in the quiet, dysfunctional town of South Park, Colorado.",
      "popularity": 405.334,
      "poster_path": "/iiCY2QIGSnmtVkIdjkKAfwDs0KF.jpg",
      "first_air_date": "1997-08-13",
      "name": "South Park",
      "vote_average": 8.358,
      "vote_count": 3843
    }
  ],
  "total_pages": 1,
  "total_results": 1
}

The genres would be Animation and Comedy. To store this I can just write the JSON to a file called TV.genre and Movie.genre, the load these at start time for fast lookups. Each movie and episode file's JSON data will need to include it's genre information. Movies already have genre_id arrays in the returned JSON but it isn't included in the first JSON block in the file. It will need to be added as a new "videolib_genres []" field. Episodes will need to add their Series genre_id array in the same manner.

VideoFE will need a way to search based on Genre. Since there aren't many for either TV or Movie it might be useful to add a 2nd row below "Movie TV" that has search options using Tab, then left/right arrows to choose an option and tab/left/right to choose a method within that option. This last part would be where a genre is selected.

Note that just typing letters jumps to Movie title, Series Title or Episode Title once the new version of the UI is implemented.

Actions

Also available in: Atom PDF