mirror of
https://github.com/mitb-archive/filebot
synced 2025-03-09 13:59:49 -04:00
Use embedded media title for filename-based bindings such as {group} {source} etc via libmediainfo
This commit is contained in:
parent
172c4954df
commit
b2438ec6a1
@ -536,13 +536,13 @@ public class MediaBindingBean {
|
|||||||
@Define("source")
|
@Define("source")
|
||||||
public String getVideoSource() {
|
public String getVideoSource() {
|
||||||
// look for video source patterns in media file and it's parent folder (use inferred media file)
|
// look for video source patterns in media file and it's parent folder (use inferred media file)
|
||||||
return releaseInfo.getVideoSource(getFileNames(getInferredMediaFile()));
|
return releaseInfo.getVideoSource(getMediaTitles());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Define("tags")
|
@Define("tags")
|
||||||
public List<String> getVideoTags() {
|
public List<String> getVideoTags() {
|
||||||
// look for video source patterns in media file and it's parent folder (use inferred media file)
|
// look for video source patterns in media file and it's parent folder (use inferred media file)
|
||||||
List<String> matches = releaseInfo.getVideoTags(getFileNames(getInferredMediaFile()));
|
List<String> matches = releaseInfo.getVideoTags(getMediaTitles());
|
||||||
if (matches.isEmpty()) {
|
if (matches.isEmpty()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -555,7 +555,7 @@ public class MediaBindingBean {
|
|||||||
|
|
||||||
@Define("s3d")
|
@Define("s3d")
|
||||||
public String getStereoscopic3D() {
|
public String getStereoscopic3D() {
|
||||||
return releaseInfo.getStereoscopic3D(getFileNames(getInferredMediaFile()));
|
return releaseInfo.getStereoscopic3D(getMediaTitles());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Define("group")
|
@Define("group")
|
||||||
@ -564,7 +564,7 @@ public class MediaBindingBean {
|
|||||||
Pattern[] nonGroupPattern = { getKeywordExcludePattern(), releaseInfo.getVideoSourcePattern(), releaseInfo.getVideoFormatPattern(true), releaseInfo.getResolutionPattern(), releaseInfo.getStructureRootPattern() };
|
Pattern[] nonGroupPattern = { getKeywordExcludePattern(), releaseInfo.getVideoSourcePattern(), releaseInfo.getVideoFormatPattern(true), releaseInfo.getResolutionPattern(), releaseInfo.getStructureRootPattern() };
|
||||||
|
|
||||||
// consider foldername, filename and original filename of inferred media file
|
// consider foldername, filename and original filename of inferred media file
|
||||||
String[] filenames = stream(getFileNames(getInferredMediaFile())).map(s -> releaseInfo.clean(s, nonGroupPattern)).filter(s -> s.length() > 0).toArray(String[]::new);
|
String[] filenames = stream(getMediaTitles()).map(s -> releaseInfo.clean(s, nonGroupPattern)).filter(s -> s.length() > 0).toArray(String[]::new);
|
||||||
|
|
||||||
// look for release group names in media file and it's parent folder
|
// look for release group names in media file and it's parent folder
|
||||||
return releaseInfo.getReleaseGroup(filenames);
|
return releaseInfo.getReleaseGroup(filenames);
|
||||||
@ -1295,17 +1295,53 @@ public class MediaBindingBean {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private String[] getFileNames(File file) {
|
private String[] getFileNames(File file) {
|
||||||
List<String> names = new ArrayList<String>(3);
|
List<String> names = new ArrayList<String>();
|
||||||
names.add(getNameWithoutExtension(file.getName())); // current file name
|
|
||||||
|
|
||||||
|
// current file name
|
||||||
|
names.add(getNameWithoutExtension(file.getName()));
|
||||||
|
|
||||||
|
// original file name via xattr
|
||||||
String original = xattr.getOriginalName(file);
|
String original = xattr.getOriginalName(file);
|
||||||
if (original != null) {
|
if (original != null) {
|
||||||
names.add(getNameWithoutExtension(original)); // original file name
|
names.add(getNameWithoutExtension(original));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// current folder name
|
||||||
File parent = file.getParentFile();
|
File parent = file.getParentFile();
|
||||||
if (parent != null && parent.getParent() != null) {
|
if (parent != null && parent.getParent() != null) {
|
||||||
names.add(parent.getName()); // current folder name
|
names.add(parent.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
return names.toArray(new String[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String[] getMediaTitles() {
|
||||||
|
File file = getInferredMediaFile();
|
||||||
|
List<String> names = new ArrayList<String>();
|
||||||
|
|
||||||
|
// current file name
|
||||||
|
names.add(getNameWithoutExtension(file.getName()));
|
||||||
|
|
||||||
|
// media title via embedded tags
|
||||||
|
try {
|
||||||
|
String title = getMediaInfo().get(StreamKind.General, 0, "Title");
|
||||||
|
if (title.length() > 0) {
|
||||||
|
names.add(title);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
debug.fine(e::toString);
|
||||||
|
}
|
||||||
|
|
||||||
|
// original file name via xattr
|
||||||
|
String original = xattr.getOriginalName(file);
|
||||||
|
if (original != null) {
|
||||||
|
names.add(getNameWithoutExtension(original));
|
||||||
|
}
|
||||||
|
|
||||||
|
// current folder name
|
||||||
|
File parent = file.getParentFile();
|
||||||
|
if (parent != null && parent.getParent() != null) {
|
||||||
|
names.add(parent.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
return names.toArray(new String[0]);
|
return names.toArray(new String[0]);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user