streamaserver / streama

Self hosted streaming media server. https://docs.streama-project.com/
MIT License
9.64k stars 986 forks source link

Clarification on show and movie regexes. #785

Open IngwiePhoenix opened 5 years ago

IngwiePhoenix commented 5 years ago

Hello!

This is neither a bug, nor a feature request - however, it would be useful to have this more clarified, so it kind of is a feature request after all.

So, most of my shows are organized by using underscores instead of spaces, and I usually do not organize by season, but by total episode count instead. For instance: The_Show/The_Show_1.mp4 would be a very basic example.

How exactly does the regex work, and how and what is it supposed to match, and what transformations can be done within a regex to replace underscores with spaces, for instance?

I am currently considering trying to find a mass-renaming tool to adjust the names of the files and folders - but being able to keep my original naming would be very helpful. This information may serve helpful to future users too, I'd think.

Kind regards, Ingwie.

dularion commented 5 years ago

So the regex needs to match 3 parts in the case of tv-show episodes: the name of the show, the season number and the episode number. Whether or not there are underscores in the name does not really matter, the resulting name will simply be sent to tmdb for a search through their database and the first hit is used. Then, within that match, it will check for the season and episode that the regex found. If that returns another hit, then this entry is used to populate the streama database.

This is due to the way that tmdb organizes shows & episodes - they are grouped by season, and it wont find a match for ongoing numbers where seasons are ignored.

I believe this ongoing-number principle is used for animes, though.. things like naruto use ever-increasing episode-numbers, all associated to "season 1" (or at least 52 of them).. see here https://www.themoviedb.org/tv/46260-naruto/season/1?language=en-US.

Basically, as long as your files contain those 3 parts, name, season, episodenumber, and based on those 3 parts you can also find it in tmdb, you should be good to go..

IngwiePhoenix commented 5 years ago

Thanks for your reply!

I tested it out on tmdb’s search and using underscores yields no results whatsoever… so looks like I have to mass-rename my files to strip out the underscores alltogether. That kinda sucks.

Yes - anime often uses ongoing episode numbers instead of seasons, because an anime’s structure is a little bit different than, let’s say, "Two and a half men". But I guess while I am at stripping underscores, I will just do this too.

It’d be nice to have a feature where a 3rd-party script can be used to determine name, season and episode, and return that, alongside the file this corresponds to, to streama for it to process it into the database. Do you think this would be do-able?

dularion commented 5 years ago

oh i was mistaken, actually streama replaces all dots and underscores with spaces in the filename, with this line of code tvShowMatcher.group('Name').replaceAll(/[._]/, " ")

So it is not tmdb that can handle it, but streama will handle it gracefully for you

dularion commented 5 years ago

Regarding a script: do you mean that you, as an admin, get a script-field where u can write some code? Or how exactly would a third-party-script be used?

IngwiePhoenix commented 5 years ago

I see. So the only reason why nothing matched was because my filenames were missing the season numbers! Good to know :)

Thanks for sharing :)

IngwiePhoenix commented 5 years ago

Regarding a script: do you mean that you, as an admin, get a script-field where u can write some code? Or how exactly would a third-party-script be used?

Sort of. For instance, consider this folder structure:

/srv/streama/
| streama.jar
| matchers/
| | anime_matcher.script

Now, I dont know what kind of scripting languages can be embedded for Java apps, but I will just use JavaScript to offer an example here - a conceptual one.

So the idea is that when bulk-adding videos, you can select a script instead of many files and let the script search for files and offer the results to Streama.

Like:

let dirs; // @var: A listing of directories within the specified folder in the settings panel. Mine is set to: /srv/streama/remote

for(let i=0; i<dirs.length; i++) {
  if(dirs[i] == "." || dirs[i] == "..") continue;
  let seriesDir = get_files_in_dir_as_array(dir[i]);
  for(let j=0; j<seriesDir.length; j++) {
    let file = path.join(streama.baseDir, dirs[i], seriesDir[j]);
    let name, season, episode = ^/(.+)_s(\d)e(\d)/ig;
    name = name.replace(/_./g, " ");
    streama.addTvShow(file, name, season, episode);
  }
}

This script would match Naruto_Shippuden_s01e05 (for example) and tell Streama about it.

Using such a method would allow small custom matchers to be written and used to match against formats that the user has already been using. Of course - an anime specific matcher might also pick up which episodes correspond to which season and instead of telling Streama about an episode 180, it could tell it "Season 2, episode 35" instead.