mirror of
https://github.com/mitb-archive/filebot
synced 2024-12-24 16:58:51 -05:00
Improve Subtitle Upload usability
This commit is contained in:
parent
62cc40136a
commit
07c64dbd61
@ -162,7 +162,7 @@ abstract class SubtitleDropTarget extends JButton {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (getSubtitleService().isAnonymous() && !Settings.isAppStore()) {
|
if (getSubtitleService().isAnonymous() && !Settings.isAppStore()) {
|
||||||
UILogger.info(String.format("%s: Please enter your login details first.", getSubtitleService().getName()));
|
UILogger.info(String.format("%s: Please enter your login details.", getSubtitleService().getName()));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -174,13 +174,7 @@ abstract class SubtitleDropTarget extends JButton {
|
|||||||
|
|
||||||
if (videoFiles.size() > 0) {
|
if (videoFiles.size() > 0) {
|
||||||
// invoke later so we don't block the DnD operation with the download dialog
|
// invoke later so we don't block the DnD operation with the download dialog
|
||||||
invokeLater(0, new Runnable() {
|
invokeLater(0, () -> handleDownload(videoFiles));
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
handleDownload(videoFiles);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -233,13 +227,13 @@ abstract class SubtitleDropTarget extends JButton {
|
|||||||
@Override
|
@Override
|
||||||
protected DropAction getDropAction(List<File> input) {
|
protected DropAction getDropAction(List<File> input) {
|
||||||
// accept video files and folders
|
// accept video files and folders
|
||||||
return (filter(input, VIDEO_FILES).size() > 0 && filter(input, SUBTITLE_FILES).size() > 0) || filter(input, FOLDERS).size() > 0 ? DropAction.Accept : DropAction.Cancel;
|
return filter(input, SUBTITLE_FILES).size() > 0 || filter(input, FOLDERS).size() > 0 ? DropAction.Accept : DropAction.Cancel;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean handleDrop(List<File> input) {
|
protected boolean handleDrop(List<File> input) {
|
||||||
if (getSubtitleService().isAnonymous()) {
|
if (getSubtitleService().isAnonymous()) {
|
||||||
UILogger.info(String.format("%s: Please enter your login details first.", getSubtitleService().getName()));
|
UILogger.info(String.format("%s: You must be logged in to upload subtitles.", getSubtitleService().getName()));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -264,13 +258,7 @@ abstract class SubtitleDropTarget extends JButton {
|
|||||||
|
|
||||||
if (uploadPlan.size() > 0) {
|
if (uploadPlan.size() > 0) {
|
||||||
// invoke later so we don't block the DnD operation with the download dialog
|
// invoke later so we don't block the DnD operation with the download dialog
|
||||||
invokeLater(0, new Runnable() {
|
invokeLater(0, () -> handleUpload(uploadPlan));
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
handleUpload(uploadPlan);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package net.filebot.ui.subtitle;
|
package net.filebot.ui.subtitle;
|
||||||
|
|
||||||
|
import static net.filebot.ui.NotificationLogging.*;
|
||||||
import static net.filebot.MediaTypes.*;
|
import static net.filebot.MediaTypes.*;
|
||||||
import static net.filebot.UserFiles.*;
|
import static net.filebot.UserFiles.*;
|
||||||
import static net.filebot.media.MediaDetection.*;
|
import static net.filebot.media.MediaDetection.*;
|
||||||
@ -155,8 +156,9 @@ public class SubtitleUploadDialog extends JDialog {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
|
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
|
||||||
table.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
|
|
||||||
try {
|
try {
|
||||||
|
getWindow(table).setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
|
||||||
|
|
||||||
SubtitleMappingTableModel model = (SubtitleMappingTableModel) table.getModel();
|
SubtitleMappingTableModel model = (SubtitleMappingTableModel) table.getModel();
|
||||||
SubtitleMapping mapping = model.getData()[table.convertRowIndexToModel(row)];
|
SubtitleMapping mapping = model.getData()[table.convertRowIndexToModel(row)];
|
||||||
|
|
||||||
@ -170,28 +172,50 @@ public class SubtitleUploadDialog extends JDialog {
|
|||||||
query = sn;
|
query = sn;
|
||||||
}
|
}
|
||||||
|
|
||||||
String input = showInputDialog("Enter movie / series name:", stripReleaseInfo(query), getStructurePathTail(video).getPath(), SubtitleUploadDialog.this);
|
final String input = showInputDialog("Enter movie / series name:", stripReleaseInfo(query), getStructurePathTail(video).getPath(), SubtitleUploadDialog.this);
|
||||||
if (input != null && input.length() > 0) {
|
if (input != null && input.length() > 0) {
|
||||||
List<SubtitleSearchResult> options = database.searchIMDB(input);
|
SwingWorker<List<SubtitleSearchResult>, Void> worker = new SwingWorker<List<SubtitleSearchResult>, Void>() {
|
||||||
if (options.size() > 0) {
|
|
||||||
SelectDialog<Movie> dialog = new SelectDialog<Movie>(SubtitleUploadDialog.this, options);
|
@Override
|
||||||
dialog.setLocation(getOffsetLocation(dialog.getOwner()));
|
protected List<SubtitleSearchResult> doInBackground() throws Exception {
|
||||||
dialog.setVisible(true);
|
return database.searchIMDB(input);
|
||||||
Movie selectedValue = dialog.getSelectedValue();
|
|
||||||
if (selectedValue != null) {
|
|
||||||
mapping.setIdentity(selectedValue);
|
|
||||||
if (mapping.getIdentity() != null && mapping.getLanguage() != null) {
|
|
||||||
mapping.setForceIdentity(true);
|
|
||||||
mapping.setState(SubtitleMapping.Status.CheckPending);
|
|
||||||
startChecking();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@Override
|
||||||
|
protected void done() {
|
||||||
|
try {
|
||||||
|
List<SubtitleSearchResult> options = get();
|
||||||
|
System.out.println(options);
|
||||||
|
if (options.size() > 0) {
|
||||||
|
SelectDialog<Movie> dialog = new SelectDialog<Movie>(SubtitleUploadDialog.this, options);
|
||||||
|
dialog.setLocation(getOffsetLocation(dialog.getOwner()));
|
||||||
|
dialog.setVisible(true);
|
||||||
|
Movie selectedValue = dialog.getSelectedValue();
|
||||||
|
if (selectedValue != null) {
|
||||||
|
mapping.setIdentity(selectedValue);
|
||||||
|
if (mapping.getIdentity() != null && mapping.getLanguage() != null && mapping.getVideo() != null) {
|
||||||
|
mapping.setForceIdentity(true);
|
||||||
|
mapping.setState(SubtitleMapping.Status.CheckPending);
|
||||||
|
startChecking();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
UILogger.warning(String.format("%s: \"%s\" not found.", database.getName(), input));
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
Logger.getLogger(SubtitleUploadDialog.class.getClass().getName()).log(Level.WARNING, e.getMessage(), e);
|
||||||
|
}
|
||||||
|
getWindow(table).setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
|
||||||
|
};
|
||||||
|
};
|
||||||
|
worker.execute();
|
||||||
|
} else {
|
||||||
|
getWindow(table).setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Logger.getLogger(SubtitleUploadDialog.class.getClass().getName()).log(Level.WARNING, e.getMessage(), e);
|
Logger.getLogger(SubtitleUploadDialog.class.getClass().getName()).log(Level.WARNING, e.toString());
|
||||||
|
getWindow(table).setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
|
||||||
}
|
}
|
||||||
table.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -266,7 +290,7 @@ public class SubtitleUploadDialog extends JDialog {
|
|||||||
public void startChecking() {
|
public void startChecking() {
|
||||||
SubtitleMapping[] data = ((SubtitleMappingTableModel) subtitleMappingTable.getModel()).getData();
|
SubtitleMapping[] data = ((SubtitleMappingTableModel) subtitleMappingTable.getModel()).getData();
|
||||||
for (SubtitleMapping it : data) {
|
for (SubtitleMapping it : data) {
|
||||||
if (it.getSubtitle() != null && it.getVideo() != null) {
|
if (it.getSubtitle() != null) {
|
||||||
if (it.getStatus() == SubtitleMapping.Status.CheckPending) {
|
if (it.getStatus() == SubtitleMapping.Status.CheckPending) {
|
||||||
checkExecutorService.submit(new CheckTask(it));
|
checkExecutorService.submit(new CheckTask(it));
|
||||||
}
|
}
|
||||||
@ -324,20 +348,20 @@ public class SubtitleUploadDialog extends JDialog {
|
|||||||
@Override
|
@Override
|
||||||
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
|
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
|
||||||
super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
|
super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
|
||||||
String text = null;
|
|
||||||
String tooltip = null;
|
|
||||||
Icon icon = null;
|
|
||||||
|
|
||||||
Movie movie = (Movie) value;
|
if (value != null) {
|
||||||
if (movie != null) {
|
Movie movie = (Movie) value;
|
||||||
text = movie.toString();
|
setText(movie.toString());
|
||||||
tooltip = String.format("%s [tt%07d]", movie.toString(), movie.getImdbId());
|
setToolTipText(String.format("%s [tt%07d]", movie.toString(), movie.getImdbId()));
|
||||||
icon = database.getIcon();
|
setIcon(database.getIcon());
|
||||||
|
setForeground(table.getForeground());
|
||||||
|
} else {
|
||||||
|
setText("<Click to select movie / series>");
|
||||||
|
setToolTipText(null);
|
||||||
|
setIcon(null);
|
||||||
|
setForeground(Color.LIGHT_GRAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
setText(text);
|
|
||||||
setToolTipText(tooltip);
|
|
||||||
setIcon(icon);
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -347,24 +371,24 @@ public class SubtitleUploadDialog extends JDialog {
|
|||||||
@Override
|
@Override
|
||||||
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
|
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
|
||||||
super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
|
super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
|
||||||
String text = null;
|
|
||||||
String tooltip = null;
|
|
||||||
Icon icon = null;
|
|
||||||
|
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
File file = (File) value;
|
File file = (File) value;
|
||||||
text = file.getName();
|
setText(file.getName());
|
||||||
tooltip = file.getPath();
|
setToolTipText(file.getPath());
|
||||||
if (SUBTITLE_FILES.accept(file)) {
|
if (SUBTITLE_FILES.accept(file)) {
|
||||||
icon = ResourceManager.getIcon("file.subtitle");
|
setIcon(ResourceManager.getIcon("file.subtitle"));
|
||||||
} else if (VIDEO_FILES.accept(file)) {
|
} else if (VIDEO_FILES.accept(file)) {
|
||||||
icon = ResourceManager.getIcon("file.video");
|
setIcon(ResourceManager.getIcon("file.video"));
|
||||||
}
|
}
|
||||||
|
setForeground(table.getForeground());
|
||||||
|
} else {
|
||||||
|
setText("<Click to select video file>");
|
||||||
|
setToolTipText(null);
|
||||||
|
setIcon(null);
|
||||||
|
setForeground(Color.LIGHT_GRAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
setText(text);
|
|
||||||
setToolTipText(text);
|
|
||||||
setIcon(icon);
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -374,29 +398,28 @@ public class SubtitleUploadDialog extends JDialog {
|
|||||||
private DefaultTableCellRenderer tableCell = new DefaultTableCellRenderer();
|
private DefaultTableCellRenderer tableCell = new DefaultTableCellRenderer();
|
||||||
private DefaultListCellRenderer listCell = new DefaultListCellRenderer();
|
private DefaultListCellRenderer listCell = new DefaultListCellRenderer();
|
||||||
|
|
||||||
private Component configure(JLabel c, Object value, boolean isSelected, boolean hasFocus) {
|
private Component configure(JLabel c, JComponent parent, Object value, boolean isSelected, boolean hasFocus) {
|
||||||
String text = null;
|
|
||||||
Icon icon = null;
|
|
||||||
|
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
Language language = (Language) value;
|
Language language = (Language) value;
|
||||||
text = language.getName();
|
c.setText(language.getName());
|
||||||
icon = ResourceManager.getFlagIcon(language.getCode());
|
c.setIcon(ResourceManager.getFlagIcon(language.getCode()));
|
||||||
|
c.setForeground(parent.getForeground());
|
||||||
|
} else {
|
||||||
|
c.setText("<Click to select language>");
|
||||||
|
c.setIcon(null);
|
||||||
|
c.setForeground(Color.LIGHT_GRAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
c.setText(text);
|
|
||||||
c.setIcon(icon);
|
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
|
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
|
||||||
return configure((DefaultTableCellRenderer) tableCell.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column), value, isSelected, hasFocus);
|
return configure((DefaultTableCellRenderer) tableCell.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column), table, value, isSelected, hasFocus);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
||||||
return configure((DefaultListCellRenderer) listCell.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus), value, isSelected, cellHasFocus);
|
return configure((DefaultListCellRenderer) listCell.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus), list, value, isSelected, cellHasFocus);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -411,7 +434,7 @@ public class SubtitleUploadDialog extends JDialog {
|
|||||||
// CheckPending, Checking, CheckFailed, AlreadyExists, Identifying, IdentificationRequired, UploadPending, Uploading, UploadComplete, UploadFailed;
|
// CheckPending, Checking, CheckFailed, AlreadyExists, Identifying, IdentificationRequired, UploadPending, Uploading, UploadComplete, UploadFailed;
|
||||||
switch ((SubtitleMapping.Status) value) {
|
switch ((SubtitleMapping.Status) value) {
|
||||||
case IllegalInput:
|
case IllegalInput:
|
||||||
text = "No video/subtitle pair";
|
text = "Please select video file";
|
||||||
icon = ResourceManager.getIcon("status.error");
|
icon = ResourceManager.getIcon("status.error");
|
||||||
break;
|
break;
|
||||||
case CheckPending:
|
case CheckPending:
|
||||||
@ -435,7 +458,7 @@ public class SubtitleUploadDialog extends JDialog {
|
|||||||
icon = ResourceManager.getIcon("action.export");
|
icon = ResourceManager.getIcon("action.export");
|
||||||
break;
|
break;
|
||||||
case IdentificationRequired:
|
case IdentificationRequired:
|
||||||
text = "Please input the missing information";
|
text = "Please select Movie / Series and Language";
|
||||||
icon = ResourceManager.getIcon("dialog.continue.invalid");
|
icon = ResourceManager.getIcon("dialog.continue.invalid");
|
||||||
break;
|
break;
|
||||||
case UploadReady:
|
case UploadReady:
|
||||||
@ -489,9 +512,9 @@ public class SubtitleUploadDialog extends JDialog {
|
|||||||
case 0:
|
case 0:
|
||||||
return "Movie / Series";
|
return "Movie / Series";
|
||||||
case 1:
|
case 1:
|
||||||
return "Video";
|
return "Video File";
|
||||||
case 2:
|
case 2:
|
||||||
return "Subtitle";
|
return "Subtitle File";
|
||||||
case 3:
|
case 3:
|
||||||
return "Language";
|
return "Language";
|
||||||
case 4:
|
case 4:
|
||||||
@ -666,7 +689,7 @@ public class SubtitleUploadDialog extends JDialog {
|
|||||||
try {
|
try {
|
||||||
CheckResult checkResult = null;
|
CheckResult checkResult = null;
|
||||||
|
|
||||||
if (!mapping.getForceIdentity()) {
|
if (!mapping.getForceIdentity() && mapping.getVideo() != null) {
|
||||||
mapping.setState(SubtitleMapping.Status.Checking);
|
mapping.setState(SubtitleMapping.Status.Checking);
|
||||||
|
|
||||||
checkResult = database.checkSubtitle(mapping.getVideo(), mapping.getSubtitle());
|
checkResult = database.checkSubtitle(mapping.getVideo(), mapping.getSubtitle());
|
||||||
@ -690,7 +713,7 @@ public class SubtitleUploadDialog extends JDialog {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mapping.getIdentity() == null) {
|
if (mapping.getIdentity() == null && mapping.getVideo() != null) {
|
||||||
mapping.setState(SubtitleMapping.Status.Identifying);
|
mapping.setState(SubtitleMapping.Status.Identifying);
|
||||||
try {
|
try {
|
||||||
if (MediaDetection.isEpisode(mapping.getVideo().getPath(), true)) {
|
if (MediaDetection.isEpisode(mapping.getVideo().getPath(), true)) {
|
||||||
@ -723,7 +746,9 @@ public class SubtitleUploadDialog extends JDialog {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mapping.getIdentity() == null || mapping.getLanguage() == null) {
|
if (mapping.getVideo() == null) {
|
||||||
|
mapping.setState(SubtitleMapping.Status.IllegalInput);
|
||||||
|
} else if (mapping.getIdentity() == null || mapping.getLanguage() == null) {
|
||||||
mapping.setState(SubtitleMapping.Status.IdentificationRequired);
|
mapping.setState(SubtitleMapping.Status.IdentificationRequired);
|
||||||
} else {
|
} else {
|
||||||
mapping.setState(SubtitleMapping.Status.UploadReady);
|
mapping.setState(SubtitleMapping.Status.UploadReady);
|
||||||
|
Loading…
Reference in New Issue
Block a user