Skip to content
This repository has been archived by the owner on Jul 5, 2022. It is now read-only.
pastapojken edited this page Jul 31, 2017 · 13 revisions

Mostly complete tutorial and info on the various scripts, not really though...

BASIC SETUP

Before doing any of this you should at least read this whole tutorial, in order to check that your folder structure and filenames are correct or to find out what options you should change.
Clone the repository to your webserver, edit the config.cfg file to match the path of media folders ( I STRONGLY recommend that you use shortcuts to your media folders, so that the full path of the files remains hidden, hence making this all more secure). You will also need to register to TMDB in order to obtain an api key, which you can find more info about here. Once you have your key, simple paste it inside the quotation marks of the TMDBapi variable, so that it looks like this: TMDBapi="abcdefghi..."
After editing the config, you will want to run "./buildDBs.sh 3" and, once that is done, "./buildHtml.sh 3". In theory you are done, now simply access the generated html through your browser and everything should simply work! (and if it's kind of broken, odds are you can simply edit the json database to fix stuff for you!)
ATTENTION!
The tv show part is waaay more complicated than the movie part of the program, as in, it kind of relies on having a specific folder structure for your tv shows/episodes. The script also gets an episode's number and season by analyzing the filename, so they have to contain this information. So, by the default, the script kind of expects a tv show to adhere to the following pattern:
/path/to/files/NameofTVshow/Season.1/NameOfTVshow.S01E01.mp4 In order to have episodes matching their seasons, all episodes of a season should be inside their own folder, so that if your tv show has the path /path/to/files/NameofTVshow/ and you have 10 seasons of it, you will have subfolders names Season.1 through Season.10, with the matching episodes inside, as the script counts the subfolders of /path/to/files/NameofTVshow/ to find out the number of available seasons.

THE CONFIG FILE

I hate to repeat myself and I WANT people to read the config file since it's all fairly self explanatory, so if you want to know the options, read the config file and you will have your answers.
However i want to clarify some things:

  • Any path to any folder/file ( so like TVpath, MoviesPath, TVhtml, Mhtml etc. ) should be relative to the location of the config file/the scripts location. So if your scripts are at /home/me/myflix/scripts, you should probably place everything in /srv/http/mydomain/myflix/ so that, TVpath, becomes for example "../TV/" (so, full path would be /srv/http/mydomain/myflix/TV/) in order for things to be more secure.
  • If your files have different names you can obviously edit the regex values. If you need more regex options you can edit parseMfilename.sh and parseTVfilename.sh, find if [[ "${filename}" =~ ${regexM} ]]; then #if filename matches regex then it's a movie we want to work on! or if [[ "${filename}" =~ ${regexTV1} ]] || [[ "${filename}" =~ ${regexTV2} ]] || [[ "${filename}" =~ ${regexTV3} ]] || [[ "${filename}" =~ ${regexTV4} ]]; then, respectively and edit them to fit your needs.
  • compression of images is done by running convert with these settings -strip -interlace Plane -gaussian-blur 0.05 -quality 85% , tinypng and compression are separate, so you can run both, either or neither, depending on the settings you choose.

What every file does

Simple run down of the function of every file, in alphabetical order:

  • bMhtml.sh builds the html for the movies' database, doesn't take any arguments
  • bTVhtml.sh builds the html for the tv shows' database, doesn't take any arguments
  • buildDBs.sh builds the databases. It takes either 1, 2 or 3 as argument, where 1 only searches in the movie path and builds the movie database, 2 only for the tv shows, and 3 for both.
    What the script actually does is run find in the set paths, searching for any ".mp4" files in that path. Once a file has been found, it passes it to parseMfilename.sh/parseTVfilename.sh.
  • buildHtml.sh builds the html. It's a wrapper for bMhtml and bTVhtml, with the same options as buildDBs.sh. So if you run buildHtml.sh 3 it will run bMhtml and then bTVhtml
  • config.cfg is simply the file that contains all the variables the scripts use. if this file is missing then the scripts will use their default values, which are the same defaults as the config's
  • getMid.sh fetches the IMDB id of a given movie. The script takes 1 argument, the name of the movie to search for, with dots instead of spaces.
    The script uses curl and grep to search for the first ID it can find in the html. ( I know, not very future proof or particularly accurate, as it takes the values arbitrarily... It's way more accurate and fast than using the TMDB api though, in my experience... )
  • getMposter.sh uses the TMDB api to fetch a poster (it arbitrarily picks the first result ) for a given movie id. The script takes one argument, the IMDB id WITHOUT "tt" at the start. It returns either the URL to the poster or, if you download the poster, the path to it.
  • getTVid.sh searches for a tv series on TMDB and returns it's TMDB id. Takes 1 argument, the name of the tv show
  • getTVposter.sh uses the TMDB api to fetch a poster (it arbitrarily picks the first result ) for a given tv show id. The script takes one argument, the TMDB id of the show and returns either the URL to the poster or, if you download the poster, the path to it.
  • parseMfilename.sh takes 1 argument, the path of the file to be parsed and added to the movie database. This is where the bulk of of the program is, it calls all the other scripts and assembles the json database
  • parseTVfilename.sh takes 1 argument, the path of the file to be parsed and added to the tv show database. This is where the bulk of of the program is, it calls all the other scripts and assembles the json database

If any of the "get" scripts fails, the matching fields in the database will either be empty or "null"

Special mentions and somewhat dumb hard coded stuff

  • parseMfilename.sh I have hard coded some things to make my life simpler. For instance, since the getMid grabs the first result, some of my movies would ALWAYS end up having the wrong ids. So there is a series of if's checking if the movie matches the filename of a given movie and assigns a predefined id that i looked up. You might want to remove these or edit them to fit your needs.
  • Common to both the parse scripts, they search for .srt subtitles that have the same filename as the file. If it finds one it will appear as English in the web page. To fix this you can manually edit the json to fit your needs.
    I plan (?) to add a simple language recognition, so if the srt file matches "filename_lang" it will be labelled as "lang", this way supporting more than 1 subtitle.
  • The parseTVfilename.sh file, if the getEpisodeName variable is set, will use the TMDB api to search for the episode name of the file that the script is working on ( this is done by using the season number and episode number, which the scripts parses off the filename, and the fetched TMDB id ). This can take a couple of seconds and since the database is built sequentially, these seconds add up...
  • I haven't tested the script with other setups besides my own so I do not know how well it handles filenames and paths and such. I have done by best to make it flexible, but I haven't tested it. Anyway the scripts expect dots instead of spaces in the filenames.
Clone this wiki locally