The cli for indexing and parsing the files for a directory.

This commit is contained in:
2017-09-09 16:11:37 +02:00
parent 60bbbb8dc2
commit 269987d3f2
2 changed files with 259 additions and 0 deletions

230
knowledgeBase.md Normal file
View File

@@ -0,0 +1,230 @@
# seasonedGuesser
The following is a description of the optimal flow for discovering mediafiles in a directory.
## Table of Contents
* [Detect changes in a directory <a name="user-content-detect-changes-in-a-directory"></a>](#detect-changes-in-a-directory-)
* [Find the files](#find-the-files)
* [Analyze the files](#analyze-the-files)
* [What to do with this information](#what-to-do-with-this-information)
* [Different ways we can say a file is interesting](#different-ways-we-can-say-a-file-is-interesting)
* [The different ways we want to accept data](#the-different-ways-we-want-to-accept-data)
* [Movies](#movies)
* [Show w/ complete season folder](#show-w-complete-season-folder)
* [Show with single episode](#show-with-single-episode)
* [Plex Local Media Assets <a name="user-content-plex-local-media-assets"></a>](#plex-local-media-assets-)
* [Enable "Local Media Assets"](#enable-local-media-assets)
* [Extra Subtitle Files](#extra-subtitle-files)
* [Local Trailers and Extras](#local-trailers-and-extras)
* [Organized in Subdirectories](#organized-in-subdirectories)
## Detect changes in a directory <a name='detect-changes-in-a-directory'></a>
There should be a daemon running to check for changes in the hash for a directory.
## Find the files <a name='find-the-files'></a>
```python
dir = somedir
os.list(dir)
```
What information do we want:
- Name of the files
- Hierarchy of the files
Runtime of `os.list()` is the real problem with the system. When collecting from network drive the speed is super slow. Need a better way to get the directory contents.
## Analyze the files <a name='analyze-the-files'></a>
Step through every file.
What information do we want:
- What the name of the file is
- Can use guessit (speed issue)
- We want to know what category of file it is
* Movie
* Episode
* Season folder
* Directory
* Subtitles
* Trash files
## What to do with this information <a name='what-to-do-with-this-information'></a>
When we know it is a movie, subtitles or episode, create a object for the type.
If it is a directory, subtitles
### Different ways we can say a file is interesting <a name='different-ways-we-can-say-a-file-is-interesting'></a>
1. If it is in a directory that has enough information
2. If it has enough information in itself to know what it is and where it belongs.
The reason we need to check this is because if a directory:
```
Twin Peaks Season 1 1080p WEB-DL DD5.1/
├── Twin Peaks S01E01
│ ├── Twin Peaks S01E01 Pilot.en.srt
│ └── Twin Peaks S01E01 Pilot.mkv
├── Twin Peaks S01E02
│ ├── Twin Peaks S01E02 Traces to Nowhere.en.srt
│ └── Twin Peaks S01E02 Traces to Nowhere.mkv
```
What do we do here?
- Do we disregard the folder name and look at the files and say that we have one mediafile [.mkv] and one subtitles file [.srt] and therefore we say we have everything we need for a element.
- Or do we look at the folder name and say say that the files inside are most likely correct and without looking at the information within the name of each element, just rename the files based on the name of the parent folder.
If we save the parent directory file name and the information within, then if the file does not have enough information we can check with the parent folder if we can extract more information about the item.
> Sidenote, this can be depremental if the file we are looking at is a sample or someother trash. Then we can accidentaly select a file that is unusefull to us.
## The different ways we want to accept data <a name='the-different-ways-we-want-to-accept-data'></a>
### Movies <a name='movies'></a>
A movie that is within a folder of the same name:
```
Interstellar.2014.1080p.BluRay.REMUX.AVC.DTS-HD.MA.5.1/
├── Interstellar.2014.1080p.BluRay.REMUX.AVC.DTS-HD.MA.5.1.eng.srt
└── Interstellar.2014.1080p.BluRay.REMUX.AVC.DTS-HD.MA.5.1.mkv
```
A movie that is standalone:
```
Interstellar.2014.1080p.BluRay.REMUX.AVC.DTS-HD.MA.5.1.mkv
```
A movie with extras:
```
Swiss.Army.Man.2016.Bluray.1080p.TrueHD-7.1.Atmos.x264-Grym/
├── Swiss.Army.Man.2016.Bluray.1080p.TrueHD-7.1.Atmos.x264-Grym.mkv
├── Swiss.Army.Man.Extras-Grym
│ ├── Behind.the.Scenes-Grym.mkv
│ ├── Deleted.Scenes-Grym.mkv
│ ├── Making.Manny-Grym.mkv
│ └── Q.and.A.Session.with.the.Filmmakers-Grym.mkv
├── Torrent downloaded from demonoid.ph.txt
└── Torrent downloaded from......txt
```
### Show w/ complete season folder <a name='show-w-complete-season-folder'></a>
A shows complete season folder with separate folder:
```
Community.720p.1080p.WEB-DL.DD5.1.H.264/S03/
├── Community S03E01
│ └── Community S03E01 Biology 101.mkv
├── Community S03E02
│ ├── Community S03E02 Geography of Global Conflict.en.srt
│ └── Community S03E02 Geography of Global Conflict.mkv
├── Community S03E03
│ ├── Community S03E03 Competitive Ecology.en.srt
│ └── Community S03E03 Competitive Ecology.mkv
```
A shows complete season folder without separate folders:
```
Penn and Teller Fool Us S01 WEB-DL x264-FUM[ettv]
├── Penn.and.Teller.Fool.Us.S01E01.WEB-DL.x264-FUM.mp4
├── Penn.and.Teller.Fool.Us.S01E02.WEB-DL.x264-FUM.mp4
├── Penn.and.Teller.Fool.Us.S01E03.WEB-DL.x264-FUM.mp4
├── Penn.and.Teller.Fool.Us.S01E04.WEB-DL.x264-FUM.mp4
├── Penn.and.Teller.Fool.Us.S01E05.WEB-DL.x264-FUM.mp4
├── Penn.and.Teller.Fool.Us.S01E06.WEB-DL.x264-FUM.mp4
├── Penn.and.Teller.Fool.Us.S01E07.WEB-DL.x264-FUM.mp4
├── Penn.and.Teller.Fool.Us.S01E08.WEB-DL.x264-FUM.mp4
├── Penn.and.Teller.Fool.Us.S01.Special.WEB-DL.x264-FUM.mp4
└── Torrent-Downloaded-From-extratorrent.cc.txt
```
### Show with single episode <a name='show-with-single-episode'></a>
A shows episode in a separate folder:
```
Twin.Peaks.S03E17.1080p.WEB.H264-STRiFE[rarbg]/
├── RARBG.txt
├── twin.peaks.s03e17.1080p.web.h264-strife.mkv
└── twin.peaks.s03e17.1080p.web.h264-strife.nfo
```
## How to group together items
Hashes are our friend! We want to take the minimal amount of separatly identifying information and hash it to a index value. This will in effect become a hash table.
**Movies:** Movie name and release year.
**Shows:** Series name, season number and episode number.
```
user@hostname:/$ echo 'interstellar.2017' | sha1sum
4ecc56e9bb3d0ef4b0b48cbe14f78974ea24ab35
```
```
user@hostname:/$ echo 'new.girl.2.17' | sha1sum
5eac346c21b3ea184a4e688cf14c8d174af12f55
```
> Replace all spaces with '.' and separate items with '.'.
> This is '.'.join(series_name) and then '.'.join([series_name, season, episode])
> NB: Episode and season number should NOT have a leading 0 here!
## Plex Local Media Assets <a name='plex-local-media-assets'></a>
### Enable "Local Media Assets"
"Local Media Assets" is an Agent source that loads local media files or embedded metadata for a media item. To do this, ensure the Agent source is enabled and topmost in the list:
* Launch the Plex Web App
* Choose Settings from the top right of the Home screen
* Select your Plex Media Server from the horizontal list
* Choose Agents
* Choose the Library Type and Agent you want to change
* Ensure Local Media Assets is checked
* Ensure Local Media Assets is topmost in the list
### Extra Subtitle Files
Several formats of subtitle files are supported and can be picked up by the Local Media Assets scanner:
* .srt
* .smi
* .ssa (or .ass)
Other formats such as VOBSUB, PGS, etc. may work on some Plex Apps but not all. If you use the Universal Transcoder, both VOBSUBS and PGS subtitles will be "burned in" during the transcoding process and shown.
Subtitle files need to be named as follows:
* `MovieName (Release Date).[Language_Code].ext`
* `Movies/MovieName (Release Date).[Language_Code].ext`
* `Movies/MovieName (Release Date).[Language_Code].forced.ext`
### Local Trailers and Extras
If you have trailers, interviews, behind the scenes videos, or other "extras" type content for your movies, you can add those.
#### Organized in Subdirectories
You can organize your local extras into specific subdirectories inside the main directory named for the movie. Extras will be detected and used if named and stored as follows:
* `Movie/MovieName (Release Date)/Extra_Directory_Type/Descriptive_name.ext`
Where `Extra_Directory_Type` is one of:
* Behind The Scenes
* Deleted Scenes
* Featurettes
* Interviews
* Scenes
* Shorts
* Trailers
It is recommended that you provide some sort of descriptive name for the extras filenames.
```
Swiss Army Man (2016)/
├── Behind The Scenes
│ └── Behind the Scenes (Local).mkv
├── Deleted Scenes
│ └── Deleted Scenes (Local).mkv
├── Featurettes
│ ├── Making Of (Local).mkv
│ └── Q and A Session with the Filmmakers (Local).mkv
└── Swiss.Army.Man.2016.Bluray.1080p.TrueHD-7.1.Atmos.x264.mkv
```