Refactor PlexNamingStandard
This commit is contained in:
parent
430d292bfe
commit
a67c466c91
|
@ -52,7 +52,7 @@ import net.filebot.Resource;
|
||||||
import net.filebot.Settings;
|
import net.filebot.Settings;
|
||||||
import net.filebot.hash.HashType;
|
import net.filebot.hash.HashType;
|
||||||
import net.filebot.media.MetaAttributes;
|
import net.filebot.media.MetaAttributes;
|
||||||
import net.filebot.media.NamingStandard;
|
import net.filebot.media.PlexNamingStandard;
|
||||||
import net.filebot.media.VideoFormat;
|
import net.filebot.media.VideoFormat;
|
||||||
import net.filebot.mediainfo.ImageMetadata;
|
import net.filebot.mediainfo.ImageMetadata;
|
||||||
import net.filebot.mediainfo.MediaInfo;
|
import net.filebot.mediainfo.MediaInfo;
|
||||||
|
@ -194,7 +194,7 @@ public class MediaBindingBean {
|
||||||
}
|
}
|
||||||
|
|
||||||
// enforce title length limit by default
|
// enforce title length limit by default
|
||||||
return truncateText(t, NamingStandard.TITLE_MAX_LENGTH);
|
return truncateText(t, PlexNamingStandard.TITLE_MAX_LENGTH);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Define("d")
|
@Define("d")
|
||||||
|
@ -1051,7 +1051,7 @@ public class MediaBindingBean {
|
||||||
|
|
||||||
@Define("plex")
|
@Define("plex")
|
||||||
public File getPlexStandardPath() throws Exception {
|
public File getPlexStandardPath() throws Exception {
|
||||||
String path = NamingStandard.Plex.getPath(infoObject);
|
String path = new PlexNamingStandard().getPath(infoObject);
|
||||||
try {
|
try {
|
||||||
path = path.concat(getSubtitleTags()); // NPE if {subt} is undefined
|
path = path.concat(getSubtitleTags()); // NPE if {subt} is undefined
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
|
@ -14,9 +14,7 @@ import net.filebot.web.EpisodeFormat;
|
||||||
import net.filebot.web.Movie;
|
import net.filebot.web.Movie;
|
||||||
import net.filebot.web.MoviePart;
|
import net.filebot.web.MoviePart;
|
||||||
|
|
||||||
public enum NamingStandard {
|
public class PlexNamingStandard {
|
||||||
|
|
||||||
Plex;
|
|
||||||
|
|
||||||
public String getPath(Object o) {
|
public String getPath(Object o) {
|
||||||
if (o instanceof Episode)
|
if (o instanceof Episode)
|
||||||
|
@ -30,20 +28,13 @@ public enum NamingStandard {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPath(Episode e) {
|
public String getPath(Episode e) {
|
||||||
// enforce title length limit by default
|
|
||||||
String episodeTitle = truncateText(EpisodeFormat.SeasonEpisode.formatMultiTitle(getMultiEpisodeList(e)), TITLE_MAX_LENGTH);
|
|
||||||
|
|
||||||
// Anime
|
|
||||||
if (isAnime(e)) {
|
if (isAnime(e)) {
|
||||||
String primaryTitle = e.getSeriesInfo().getName();
|
// Anime
|
||||||
String episode = String.join(" - ", primaryTitle, EpisodeFormat.SeasonEpisode.formatSxE(e), episodeTitle);
|
return path(getSeriesFolder(), getSeriesFolder(e), getEpisodeName(e));
|
||||||
return path(getAnimeFolder(), primaryTitle, episode);
|
} else {
|
||||||
|
// TV Series
|
||||||
|
return path(getSeriesFolder(), getSeriesFolder(e), getSeasonFolder(e), getEpisodeName(e));
|
||||||
}
|
}
|
||||||
|
|
||||||
// TV Series
|
|
||||||
String episode = String.join(" - ", e.getSeriesName(), EpisodeFormat.SeasonEpisode.formatS00E00(e), episodeTitle);
|
|
||||||
String season = e.getSpecial() != null ? getSpecialFolder(e.getSeason()) : e.getSeason() != null ? getSeasonFolder(e.getSeason()) : null;
|
|
||||||
return path(getSeriesFolder(), e.getSeriesName(), season, episode);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPath(Movie m) {
|
public String getPath(Movie m) {
|
||||||
|
@ -104,12 +95,50 @@ public enum NamingStandard {
|
||||||
return "Music";
|
return "Music";
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getSpecialFolder(Integer season) {
|
public String getSeriesFolder(Episode e) {
|
||||||
return "Specials";
|
return formatSeriesName(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getSeasonFolder(Integer season) {
|
public String getSeasonFolder(Episode e) {
|
||||||
return String.format("Season %02d", season == null ? 0 : season);
|
if (e.getSpecial() != null) {
|
||||||
|
return "Specials";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (e.getSeason() != null) {
|
||||||
|
return String.format("Season %02d", e.getSeason());
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getEpisodeName(Episode e) {
|
||||||
|
return String.join(" - ", formatSeriesName(e), formatEpisodeNumbers(e), formatEpisodeTitle(e));
|
||||||
|
}
|
||||||
|
|
||||||
|
public String formatSeriesName(Episode e) {
|
||||||
|
if (isAnime(e)) {
|
||||||
|
// Anime
|
||||||
|
return e.getSeriesInfo().getName(); // series info name is the primary Anime name
|
||||||
|
} else {
|
||||||
|
// TV Series
|
||||||
|
return e.getSeriesName();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String formatEpisodeNumbers(Episode e) {
|
||||||
|
if (isAnime(e)) {
|
||||||
|
// Anime
|
||||||
|
return EpisodeFormat.SeasonEpisode.formatSxE(e);
|
||||||
|
} else {
|
||||||
|
// TV Series
|
||||||
|
return EpisodeFormat.SeasonEpisode.formatS00E00(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public String formatEpisodeTitle(Episode e) {
|
||||||
|
// enforce title length limit by default
|
||||||
|
return truncateText(EpisodeFormat.SeasonEpisode.formatMultiTitle(getMultiEpisodeList(e)), TITLE_MAX_LENGTH);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final int TITLE_MAX_LENGTH = 150;
|
public static final int TITLE_MAX_LENGTH = 150;
|
Loading…
Reference in New Issue