* updated AnidbClient (due to changes of the website)
* not logging exception stacktraces anymore
This commit is contained in:
parent
bc9eb0a267
commit
0d90d19d05
|
@ -13,13 +13,12 @@ public class Main {
|
|||
* @param args
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).setLevel(Level.ALL);
|
||||
|
||||
try {
|
||||
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
|
||||
} catch (Exception e) {
|
||||
// should not happen
|
||||
Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).log(Level.SEVERE, e.getMessage(), e);
|
||||
Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).log(Level.SEVERE, e.toString());
|
||||
}
|
||||
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
|
|
|
@ -135,7 +135,7 @@ public class FileBotList extends JPanel implements Saveable, TransferablePolicyS
|
|||
out.close();
|
||||
} catch (FileNotFoundException e) {
|
||||
// should not happen
|
||||
Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).log(Level.SEVERE, e.getMessage(), e);
|
||||
Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).log(Level.SEVERE, e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -193,7 +193,7 @@ public class FileBotTree extends JTree implements TransferablePolicySupport {
|
|||
Desktop.getDesktop().open(file);
|
||||
} catch (Exception e) {
|
||||
MessageManager.showWarning(e.getMessage());
|
||||
Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).log(Level.SEVERE, e.getMessage(), e);
|
||||
Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).log(Level.SEVERE, e.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,10 +2,6 @@
|
|||
package net.sourceforge.filebot.ui;
|
||||
|
||||
|
||||
import java.awt.datatransfer.DataFlavor;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.swing.Action;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.KeyStroke;
|
||||
|
@ -36,20 +32,6 @@ public class FileBotUtil {
|
|||
return filename.replaceAll("[\\\\/:*?\"<>|]", "");
|
||||
}
|
||||
|
||||
public static final DataFlavor uriListFlavor = createUriListFlavor();
|
||||
|
||||
|
||||
private static DataFlavor createUriListFlavor() {
|
||||
try {
|
||||
return new DataFlavor("text/uri-list;class=java.lang.String");
|
||||
} catch (ClassNotFoundException e) {
|
||||
// will never happen
|
||||
Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).log(Level.SEVERE, e.getMessage(), e);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public static Throwable getRootCause(Throwable t) {
|
||||
while (t.getCause() != null) {
|
||||
|
|
|
@ -183,7 +183,7 @@ public class SplitPanel extends ToolPanel implements ChangeListener {
|
|||
tree.setModel(model);
|
||||
} catch (Exception e) {
|
||||
// should not happen
|
||||
Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).log(Level.SEVERE, e.getMessage(), e);
|
||||
Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).log(Level.SEVERE, e.toString());
|
||||
}
|
||||
|
||||
SplitPanel.this.firePropertyChange(LOADING_PROPERTY, null, false);
|
||||
|
|
|
@ -131,7 +131,7 @@ public class TypePanel extends ToolPanel {
|
|||
tree.setModel(model);
|
||||
} catch (Exception e) {
|
||||
// should not happen
|
||||
Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).log(Level.SEVERE, e.getMessage(), e);
|
||||
Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).log(Level.SEVERE, e.toString());
|
||||
}
|
||||
|
||||
TypePanel.this.firePropertyChange(LOADING_PROPERTY, null, false);
|
||||
|
|
|
@ -52,7 +52,7 @@ public class FileListTransferablePolicy extends FileTransferablePolicy {
|
|||
}
|
||||
} catch (IOException e) {
|
||||
// should not happen
|
||||
Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).log(Level.SEVERE, e.getMessage(), e);
|
||||
Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).log(Level.SEVERE, e.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -72,7 +72,7 @@ public class NamesRenameListTransferablePolicy extends MultiTransferablePolicy {
|
|||
}
|
||||
} catch (Exception e) {
|
||||
// should not happen
|
||||
Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).log(Level.SEVERE, e.getMessage(), e);
|
||||
Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).log(Level.SEVERE, e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ public class HyperlinkLabel extends JLabel {
|
|||
Desktop.getDesktop().browse(url.toURI());
|
||||
} catch (Exception e) {
|
||||
// should not happen
|
||||
Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).log(Level.SEVERE, e.getMessage(), e);
|
||||
Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).log(Level.SEVERE, e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -326,7 +326,7 @@ public class SearchPanel extends FileBotPanel {
|
|||
tabbedPane.remove(episodeList);
|
||||
|
||||
MessageManager.showWarning(FileBotUtil.getRootCause(e).getMessage());
|
||||
Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).log(Level.SEVERE, e.getMessage(), e);
|
||||
Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).log(Level.SEVERE, e.toString());
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -407,7 +407,7 @@ public class SearchPanel extends FileBotPanel {
|
|||
tabbedPane.remove(episodeList);
|
||||
|
||||
MessageManager.showWarning(FileBotUtil.getRootCause(e).getMessage());
|
||||
Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).log(Level.SEVERE, e.getMessage(), e);
|
||||
Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).log(Level.SEVERE, e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -165,7 +165,7 @@ public class SfvTable extends JTable implements TransferablePolicySupport, Savea
|
|||
out.close();
|
||||
} catch (FileNotFoundException e) {
|
||||
// should not happen
|
||||
Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).log(Level.SEVERE, e.getMessage(), e);
|
||||
Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).log(Level.SEVERE, e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -100,7 +100,7 @@ public class SfvTransferablePolicy extends MultiTransferablePolicy {
|
|||
in.close();
|
||||
} catch (IOException e) {
|
||||
// should not happen
|
||||
Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).log(Level.SEVERE, e.getMessage(), e);
|
||||
Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).log(Level.SEVERE, e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -9,15 +9,29 @@ import java.io.File;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import net.sourceforge.filebot.ui.FileBotUtil;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
|
||||
public class FileTransferable implements Transferable {
|
||||
|
||||
public static final DataFlavor uriListFlavor = createUriListFlavor();
|
||||
|
||||
|
||||
private static DataFlavor createUriListFlavor() {
|
||||
try {
|
||||
return new DataFlavor("text/uri-list;class=java.lang.String");
|
||||
} catch (ClassNotFoundException e) {
|
||||
// will never happen
|
||||
Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).log(Level.SEVERE, e.toString());
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private List<File> files;
|
||||
|
||||
private DataFlavor[] supportedFlavors = { DataFlavor.javaFileListFlavor, FileBotUtil.uriListFlavor };
|
||||
private DataFlavor[] supportedFlavors = { DataFlavor.javaFileListFlavor, uriListFlavor };
|
||||
|
||||
|
||||
public FileTransferable(File... fileArray) {
|
||||
|
@ -38,7 +52,7 @@ public class FileTransferable implements Transferable {
|
|||
public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException {
|
||||
if (flavor.isFlavorJavaFileListType())
|
||||
return files;
|
||||
else if (flavor.equals(FileBotUtil.uriListFlavor))
|
||||
else if (flavor.equals(uriListFlavor))
|
||||
return getUriList();
|
||||
else
|
||||
throw new UnsupportedFlavorException(flavor);
|
||||
|
@ -74,4 +88,5 @@ public class FileTransferable implements Transferable {
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ public class SaveableExportHandler implements ExportHandler {
|
|||
}
|
||||
} catch (Exception e) {
|
||||
// should not happen
|
||||
Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).log(Level.SEVERE, e.getMessage(), e);
|
||||
Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).log(Level.SEVERE, e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -64,7 +64,7 @@ public class SaveableExportHandler implements ExportHandler {
|
|||
return new FileTransferable(temporaryFile);
|
||||
} catch (IOException e) {
|
||||
// should not happen
|
||||
Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).log(Level.SEVERE, e.getMessage(), e);
|
||||
Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).log(Level.SEVERE, e.toString());
|
||||
}
|
||||
|
||||
return null;
|
||||
|
|
|
@ -4,7 +4,9 @@ package net.sourceforge.filebot.ui.transferablepolicies;
|
|||
|
||||
import java.awt.datatransfer.DataFlavor;
|
||||
import java.awt.datatransfer.Transferable;
|
||||
import java.awt.datatransfer.UnsupportedFlavorException;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
|
@ -12,7 +14,7 @@ import java.util.List;
|
|||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.sourceforge.filebot.ui.FileBotUtil;
|
||||
import net.sourceforge.filebot.ui.transfer.FileTransferable;
|
||||
|
||||
|
||||
public abstract class FileTransferablePolicy extends TransferablePolicy {
|
||||
|
@ -36,8 +38,8 @@ public abstract class FileTransferablePolicy extends TransferablePolicy {
|
|||
try {
|
||||
if (tr.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) {
|
||||
return (List<File>) tr.getTransferData(DataFlavor.javaFileListFlavor);
|
||||
} else if (tr.isDataFlavorSupported(FileBotUtil.uriListFlavor)) {
|
||||
String transferString = (String) tr.getTransferData(FileBotUtil.uriListFlavor);
|
||||
} else if (tr.isDataFlavorSupported(FileTransferable.uriListFlavor)) {
|
||||
String transferString = (String) tr.getTransferData(FileTransferable.uriListFlavor);
|
||||
|
||||
String lines[] = transferString.split("\r?\n");
|
||||
ArrayList<File> files = new ArrayList<File>(lines.length);
|
||||
|
@ -61,9 +63,12 @@ public abstract class FileTransferablePolicy extends TransferablePolicy {
|
|||
|
||||
return files;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
} catch (UnsupportedFlavorException e) {
|
||||
// should not happen
|
||||
Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).log(Level.SEVERE, e.getMessage(), e);
|
||||
Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).log(Level.SEVERE, e.toString());
|
||||
} catch (IOException e) {
|
||||
// should not happen
|
||||
Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).log(Level.SEVERE, e.toString());
|
||||
}
|
||||
|
||||
return null;
|
||||
|
|
|
@ -31,7 +31,7 @@ public abstract class TextTransferablePolicy extends TransferablePolicy {
|
|||
load(string);
|
||||
} catch (Exception e) {
|
||||
// should not happen
|
||||
Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).log(Level.SEVERE, e.getMessage(), e);
|
||||
Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).log(Level.SEVERE, e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -48,11 +48,11 @@ public class AnidbClient extends EpisodeListClient {
|
|||
|
||||
if (!nodes.isEmpty())
|
||||
for (Node node : nodes) {
|
||||
String type = XPathUtil.selectString("./TD[2]/text()", node);
|
||||
String type = XPathUtil.selectString("./TD[3]/text()", node);
|
||||
|
||||
// we only want shows
|
||||
if (type.equalsIgnoreCase("tv series")) {
|
||||
Node titleNode = XPathUtil.selectNode("./TD[1]/A", node);
|
||||
Node titleNode = XPathUtil.selectNode("./TD[2]/A", node);
|
||||
|
||||
String title = XPathUtil.selectString("text()", titleNode);
|
||||
String href = XPathUtil.selectString("@href", titleNode);
|
||||
|
@ -103,7 +103,7 @@ public class AnidbClient extends EpisodeListClient {
|
|||
|
||||
for (Node node : nodes) {
|
||||
String number = XPathUtil.selectString("./TD[1]/A/text()", node);
|
||||
String title = XPathUtil.selectString("./TD[2]/SPAN/text()", node);
|
||||
String title = XPathUtil.selectString("./TD[2]/LABEL/text()", node);
|
||||
|
||||
if (title.startsWith("recap"))
|
||||
title = title.replaceFirst("recap", "");
|
||||
|
|
|
@ -147,7 +147,7 @@ public class DownloadTask extends SwingWorker<ByteBuffer, Object> {
|
|||
sb.append(URLEncoder.encode(parameters.get(key), "UTF-8"));
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
// will never happen
|
||||
Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).log(Level.SEVERE, e.getMessage(), e);
|
||||
Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).log(Level.SEVERE, e.toString());
|
||||
}
|
||||
|
||||
i++;
|
||||
|
|
|
@ -8,12 +8,18 @@ import java.net.URL;
|
|||
public class MovieDescriptor {
|
||||
|
||||
private String title;
|
||||
private int year;
|
||||
private int imdbId;
|
||||
private Integer imdbId;
|
||||
|
||||
private Integer year;
|
||||
private URL imdbUrl;
|
||||
|
||||
|
||||
public MovieDescriptor(String title, int year, int imdbId, URL imdbUrl) {
|
||||
public MovieDescriptor(String description, Integer imdbId) {
|
||||
this(description, imdbId, null, null);
|
||||
}
|
||||
|
||||
|
||||
public MovieDescriptor(String title, Integer imdbId, Integer year, URL imdbUrl) {
|
||||
this.title = title;
|
||||
this.imdbId = imdbId;
|
||||
this.year = year;
|
||||
|
@ -26,13 +32,13 @@ public class MovieDescriptor {
|
|||
}
|
||||
|
||||
|
||||
public int getYear() {
|
||||
return year;
|
||||
public Integer getImdbId() {
|
||||
return imdbId;
|
||||
}
|
||||
|
||||
|
||||
public int getImdbId() {
|
||||
return imdbId;
|
||||
public Integer getYear() {
|
||||
return year;
|
||||
}
|
||||
|
||||
|
||||
|
@ -43,6 +49,9 @@ public class MovieDescriptor {
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
if (year == null)
|
||||
return title;
|
||||
|
||||
return String.format("%s (%d)", title, year);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ public class OpenSubtitlesClient {
|
|||
* </tr>
|
||||
* </table>
|
||||
*/
|
||||
private String url = "http://dev.opensubtitles.org/xml-rpc";
|
||||
private String url = "http://www.opensubtitles.org/xml-rpc";
|
||||
|
||||
private String username;
|
||||
private String password;
|
||||
|
@ -52,7 +52,7 @@ public class OpenSubtitlesClient {
|
|||
/**
|
||||
* Interval to call NoOperation to keep the session from expiring
|
||||
*/
|
||||
public static final int KEEP_ALIVE_INTERVAL = 12 * 60 * 1000; // 12 minutes
|
||||
private static final int KEEP_ALIVE_INTERVAL = 12 * 60 * 1000; // 12 minutes
|
||||
|
||||
|
||||
public OpenSubtitlesClient(String useragent) {
|
||||
|
@ -93,8 +93,6 @@ public class OpenSubtitlesClient {
|
|||
this.username = username;
|
||||
this.password = password;
|
||||
this.language = language;
|
||||
|
||||
activate();
|
||||
}
|
||||
|
||||
|
||||
|
@ -216,13 +214,34 @@ public class OpenSubtitlesClient {
|
|||
|
||||
ArrayList<OpenSubtitleDescriptor> subs = new ArrayList<OpenSubtitleDescriptor>();
|
||||
|
||||
for (Map<String, String> subtitle : response.get("data"))
|
||||
if (!(response.get("data") instanceof List))
|
||||
throw new XmlRpcException("Illegal response: " + response.toString());
|
||||
|
||||
// if there was an error data may not be a list
|
||||
for (Map<String, String> subtitle : response.get("data")) {
|
||||
subs.add(new OpenSubtitleDescriptor(subtitle));
|
||||
}
|
||||
|
||||
return subs;
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<MovieDescriptor> searchMoviesOnIMDB(String query) throws XmlRpcFault {
|
||||
activate();
|
||||
|
||||
Map<String, List<Map<String, String>>> response = (Map<String, List<Map<String, String>>>) invoke("SearchMoviesOnIMDB", token, query);
|
||||
|
||||
ArrayList<MovieDescriptor> movies = new ArrayList<MovieDescriptor>();
|
||||
|
||||
for (Map<String, String> movie : response.get("data")) {
|
||||
movies.add(new MovieDescriptor(movie.get("title"), new Integer(movie.get("id"))));
|
||||
}
|
||||
|
||||
return movies;
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public boolean noOperation() {
|
||||
try {
|
||||
|
|
Loading…
Reference in New Issue