diff --git a/README.md b/README.md index 246799f..a53114e 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ An open source desktop application for downloading and managing your Audible aud [Download](https://github.com/openaudible/openaudible/releases/latest) installers for Windows, Mac and Linux. -More information is available at the project home page [OpenAudible](http://openaudible.org). +More information is available at the project home page [openaudible.org](http://openaudible.org). ## Features - Import audible books from your account @@ -81,7 +81,7 @@ java -cp "target/openaudible-jar-with-dependencies.jar:swt/org.eclipse.swt.gtk.l #### Notes -Running with -ea to alert you of assertion failures is recommended for debugging. We use a lot of "asserts" to help identify problems. +Running with -ea to alert you of assertion failures is recommended for debugging. We use "asserts" to help identify problems. Enter that into the VM Arguments on your debugger/run dialog if using an IDE. @@ -102,7 +102,7 @@ Some effort was made to separate the SWT GUI from the core code, which can be us - [Eclipse SWT](http://www.eclipse.org/swt/) - Standard Widget Toolkit - [HTML Unit](https://htmlunit.sourceforge.net/) - HTML web page scraping -- [InAudible-NG](https://github.com/inAudible-NG/RainbowCrack-NG) - Key discovery +- [InAudible-NG](https://github.com/inAudible-NG/) - Decode ## Contributing diff --git a/src/main/java/org/openaudible/Audible.java b/src/main/java/org/openaudible/Audible.java index feb228f..d6f5d6e 100644 --- a/src/main/java/org/openaudible/Audible.java +++ b/src/main/java/org/openaudible/Audible.java @@ -98,7 +98,7 @@ public class Audible implements IQueueListener { } - public void initConverter() throws IOException { + public void initConverter() { convertQueue = new ConvertQueue(); convertToMP3 = true; convertQueue.addListener(this); @@ -659,7 +659,7 @@ public class Audible implements IQueueListener { return out; } - public void setExternalCookies(AudibleScraper s, Collection cookies) throws Exception { + public void setExternalCookies(AudibleScraper s, Collection cookies) { CookieManager cm = s.getWebClient().getCookieManager(); // try { diff --git a/src/main/java/org/openaudible/AudibleCLI.java b/src/main/java/org/openaudible/AudibleCLI.java index b063f84..65e1720 100644 --- a/src/main/java/org/openaudible/AudibleCLI.java +++ b/src/main/java/org/openaudible/AudibleCLI.java @@ -17,7 +17,7 @@ import java.util.logging.Level; public class AudibleCLI { private static final Log LOG = LogFactory.getLog(AudibleCLI.class); - final Audible audible= new Audible();; + final Audible audible= new Audible(); volatile boolean quit = false; public AudibleCLI() { @@ -247,7 +247,7 @@ public class AudibleCLI { println("Done " + f); } - private void test(List bookList) throws Exception { + private void test(List bookList) { for (Book b : bookList) { diff --git a/src/main/java/org/openaudible/audible/AudibleScraper.java b/src/main/java/org/openaudible/audible/AudibleScraper.java index 29b5234..bf6f875 100644 --- a/src/main/java/org/openaudible/audible/AudibleScraper.java +++ b/src/main/java/org/openaudible/audible/AudibleScraper.java @@ -236,7 +236,7 @@ public class AudibleScraper { - ArrayList parseLibraryFragment(DomDocumentFragment fragment) throws IOException { + ArrayList parseLibraryFragment(DomDocumentFragment fragment) { ArrayList list = new ArrayList<>(); ArrayList colNames = new ArrayList<>(); @@ -538,7 +538,7 @@ public class AudibleScraper { } } - public void signOut() throws FailingHttpStatusCodeException, IOException, InterruptedException { + public void signOut() throws FailingHttpStatusCodeException, IOException { if (getProgress() != null) getProgress().setTask("Signing out"); setURL("/signout"); @@ -905,7 +905,7 @@ public class AudibleScraper { return null; } - private boolean parseBookPage(HtmlPage page, Book b) throws Exception { + private boolean parseBookPage(HtmlPage page, Book b) { DomNode h = page; if (getProgress() != null) getProgress().setTask("Parsing book", b.toString()); diff --git a/src/main/java/org/openaudible/audible/ConnectionListener.java b/src/main/java/org/openaudible/audible/ConnectionListener.java index f998b19..d286965 100644 --- a/src/main/java/org/openaudible/audible/ConnectionListener.java +++ b/src/main/java/org/openaudible/audible/ConnectionListener.java @@ -6,7 +6,7 @@ import org.openaudible.AudibleAccountPrefs; * Created 6/27/2017. */ public interface ConnectionListener { - public void connectionChanged(boolean connected); - public AudibleAccountPrefs getAccountPrefs(AudibleAccountPrefs in); + void connectionChanged(boolean connected); + AudibleAccountPrefs getAccountPrefs(AudibleAccountPrefs in); } diff --git a/src/main/java/org/openaudible/convert/ConvertJob.java b/src/main/java/org/openaudible/convert/ConvertJob.java index cdcb15d..d341946 100644 --- a/src/main/java/org/openaudible/convert/ConvertJob.java +++ b/src/main/java/org/openaudible/convert/ConvertJob.java @@ -49,7 +49,7 @@ public class ConvertJob implements IQueueJob, LineListener { return "convert " + book; } - private String getExecutable() throws IOException { + private String getExecutable() { return FFMPEG.getExecutable(); } @@ -57,7 +57,7 @@ public class ConvertJob implements IQueueJob, LineListener { // take status from ffmpeg, example: // frame= 1 fps=0.0 q=0.0 size= 2kB time=06:17:11.44 bitrate= 0.0kbits/s @Override - public void takeLine(String s) throws Exception { + public void takeLine(String s) { String find = "time="; int ch = s.indexOf(find); if (ch!=-1) { diff --git a/src/main/java/org/openaudible/convert/ConvertQueue.java b/src/main/java/org/openaudible/convert/ConvertQueue.java index 46f6cf7..a5964ce 100644 --- a/src/main/java/org/openaudible/convert/ConvertQueue.java +++ b/src/main/java/org/openaudible/convert/ConvertQueue.java @@ -5,7 +5,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.openaudible.Audible; import org.openaudible.books.Book; -import org.openaudible.progress.IProgressTask; import org.openaudible.util.queues.IQueueJob; import org.openaudible.util.queues.JobProgress; import org.openaudible.util.queues.ThreadedQueue; diff --git a/src/main/java/org/openaudible/desktop/swt/gui/progress/ProgressDialog.java b/src/main/java/org/openaudible/desktop/swt/gui/progress/ProgressDialog.java index b4c6021..8234ca8 100644 --- a/src/main/java/org/openaudible/desktop/swt/gui/progress/ProgressDialog.java +++ b/src/main/java/org/openaudible/desktop/swt/gui/progress/ProgressDialog.java @@ -371,7 +371,7 @@ public class ProgressDialog extends ProgressMonitorDialog { } class LongRunningOperation implements IRunnableWithProgress { - public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { + public void run(IProgressMonitor monitor) throws InterruptedException { // DebugLog.println("Running task"); monitor.beginTask("Running task ", IProgressMonitor.UNKNOWN); if (simpleThread != null) { diff --git a/src/main/java/org/openaudible/desktop/swt/gui/progress/ProgressTask.java b/src/main/java/org/openaudible/desktop/swt/gui/progress/ProgressTask.java index f19c702..c37c6e8 100644 --- a/src/main/java/org/openaudible/desktop/swt/gui/progress/ProgressTask.java +++ b/src/main/java/org/openaudible/desktop/swt/gui/progress/ProgressTask.java @@ -37,7 +37,7 @@ public class ProgressTask extends Thread implements IProgressTask { progress.getProgressMonitor().beginTask(name, totalWork); } - public void worked(int i) throws InterruptedException { + public void worked(int i) { progress.getProgressMonitor().worked(i); } diff --git a/src/main/java/org/openaudible/desktop/swt/manager/Application.java b/src/main/java/org/openaudible/desktop/swt/manager/Application.java index cd20b23..39b659b 100644 --- a/src/main/java/org/openaudible/desktop/swt/manager/Application.java +++ b/src/main/java/org/openaudible/desktop/swt/manager/Application.java @@ -1,31 +1,15 @@ package org.openaudible.desktop.swt.manager; -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import org.eclipse.swt.SWT; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Event; -import org.eclipse.swt.widgets.FileDialog; -import org.openaudible.Audible; -import org.openaudible.AudibleAccountPrefs; -import org.openaudible.AudibleRegion; -import org.openaudible.Directories; -import org.openaudible.books.BookNotifier; import org.openaudible.desktop.swt.gui.GUI; -import org.openaudible.desktop.swt.gui.MessageBoxFactory; import org.openaudible.desktop.swt.gui.SWTAsync; -import org.openaudible.desktop.swt.gui.progress.ProgressDialog; -import org.openaudible.desktop.swt.gui.progress.ProgressTask; import org.openaudible.desktop.swt.manager.menu.AppMenu; import org.openaudible.desktop.swt.manager.menu.CommandCenter; import org.openaudible.desktop.swt.manager.views.MainWindow; import org.openaudible.desktop.swt.util.shop.PaintShop; -import org.openaudible.util.HTMLUtil; - -import java.io.File; -import java.io.IOException; public class Application extends GUI { diff --git a/src/main/java/org/openaudible/desktop/swt/manager/AudibleGUI.java b/src/main/java/org/openaudible/desktop/swt/manager/AudibleGUI.java index 45f6b79..6bbd64d 100644 --- a/src/main/java/org/openaudible/desktop/swt/manager/AudibleGUI.java +++ b/src/main/java/org/openaudible/desktop/swt/manager/AudibleGUI.java @@ -70,7 +70,7 @@ public class AudibleGUI implements BookListener, ConnectionListener { public boolean checkFFMPEG() { try { - Thread.sleep(8000); + // Thread.sleep(4000); String vers = FFMPEG.getVersion(); LOG.info("using " + vers); hasFFMPEG = true; @@ -100,7 +100,6 @@ public class AudibleGUI implements BookListener, ConnectionListener { // converting aax to mp3. audible.convertQueue.addListener(queueListener); - new Thread(() -> checkFFMPEG()).start(); ConnectionNotifier.instance.addListener(this); @@ -305,7 +304,9 @@ public class AudibleGUI implements BookListener, ConnectionListener { } public void convertMP3(Collection list) { + bookNotifier.setEnabled(false); audible.convertQueue.addAll(list); + bookNotifier.setEnabled(true); bookNotifier.booksUpdated(); } @@ -479,12 +480,10 @@ public class AudibleGUI implements BookListener, ConnectionListener { public boolean canViewInAudible() { Book b = onlyOneSelected(); if (b != null) { - if (!b.getInfoLink().isEmpty()) - return true; + return !b.getInfoLink().isEmpty(); // might have to search... // Can search for Product_ID and get one result.. - return false; } return false; } @@ -496,8 +495,7 @@ public class AudibleGUI implements BookListener, ConnectionListener { Book b = onlyOneSelected(); if (b != null) { - if (audible.hasMP3(b)) - return true; + return audible.hasMP3(b); } @@ -699,6 +697,7 @@ public class AudibleGUI implements BookListener, ConnectionListener { @Override public void booksUpdated() { + // TODO: Ensure this isn't called too frequently. audible.updateFileCache(); int d = 0; int c = 0; @@ -948,9 +947,9 @@ public class AudibleGUI implements BookListener, ConnectionListener { if (prefsFile.exists()) { String content = HTMLUtil.readFile(prefsFile); prefs = gson.fromJson(content, Prefs.class); - - } + + } catch (Throwable th) { LOG.info("Error loading prefs", th); prefs = new Prefs(); @@ -997,6 +996,7 @@ public class AudibleGUI implements BookListener, ConnectionListener { BookNotifier.getInstance().booksUpdated(); backgroundVersionCheck(); + new Thread(() -> checkFFMPEG()).start(); } catch (Exception e) { diff --git a/src/main/java/org/openaudible/desktop/swt/manager/Version.java b/src/main/java/org/openaudible/desktop/swt/manager/Version.java index 3aa5bc2..1cf3be6 100644 --- a/src/main/java/org/openaudible/desktop/swt/manager/Version.java +++ b/src/main/java/org/openaudible/desktop/swt/manager/Version.java @@ -2,11 +2,11 @@ package org.openaudible.desktop.swt.manager; public interface Version { - final String appName = "OpenAudible"; - final String appVersion = "0.9.4"; - final boolean appDebug = false; - final String appLink = "http://openaudible.org"; - final String versionLink = "http://openaudible.org/swt_version.json"; - final String client = "org.openaudible.desktop.swt"; + String appName = "OpenAudible"; + String appVersion = "1.0"; + boolean appDebug = false; + String appLink = "http://openaudible.org"; + String versionLink = "http://openaudible.org/swt_version.json"; + String client = "org.openaudible.desktop.swt"; } diff --git a/src/main/java/org/openaudible/desktop/swt/manager/VersionCheck.java b/src/main/java/org/openaudible/desktop/swt/manager/VersionCheck.java index 4edbc0c..c635cf7 100644 --- a/src/main/java/org/openaudible/desktop/swt/manager/VersionCheck.java +++ b/src/main/java/org/openaudible/desktop/swt/manager/VersionCheck.java @@ -15,6 +15,8 @@ public enum VersionCheck { instance; private static final Log LOG = LogFactory.getLog(VersionCheck.class); + + // if verbose return state regardless. // if !verbose, only alert when new version is available. public void checkForUpdate(Shell shell, boolean verbose) { @@ -25,6 +27,13 @@ public enum VersionCheck { int diff = obj.get("diff").getAsInt(); if (diff < 0) { MessageBoxFactory.showGeneral(shell, SWT.ICON_INFORMATION, title, msg); + if (obj.has("site")) + { + String url = obj.get("site").getAsString(); + AudibleGUI.instance.browse(url); + } + + // TODO: Add buttons: go to web site (openaudible.org) or download update (go to mac,win, or linux download url) } else { if (verbose) @@ -84,7 +93,7 @@ public enum VersionCheck { JsonObject obj =null; try { obj = getVersion(); - LOG.info(obj.toString()); + if (!obj.has("version")) throw new IOException("missing version field\n" + obj); String releaseVersion = obj.get("version").getAsString(); @@ -96,6 +105,7 @@ public enum VersionCheck { if (diff<0) { title = "Update Available"; msg = "An update is available!\nYour version: " + Version.appVersion + "\nRelease Version:" + releaseVersion; + }else if (diff>0) { title = "Using Pre-release"; msg = "You appear to be using a pre-release version\nYour version: " + Version.appVersion + "\nLatest Version:" + releaseVersion; diff --git a/src/main/java/org/openaudible/desktop/swt/manager/menu/CommandCenter.java b/src/main/java/org/openaudible/desktop/swt/manager/menu/CommandCenter.java index 864083c..4015419 100644 --- a/src/main/java/org/openaudible/desktop/swt/manager/menu/CommandCenter.java +++ b/src/main/java/org/openaudible/desktop/swt/manager/menu/CommandCenter.java @@ -16,11 +16,11 @@ import org.openaudible.desktop.swt.manager.Application; import org.openaudible.desktop.swt.manager.AudibleGUI; import org.openaudible.desktop.swt.manager.Version; import org.openaudible.desktop.swt.manager.VersionCheck; +import org.openaudible.desktop.swt.manager.views.AboutDialog; import org.openaudible.desktop.swt.manager.views.AudibleBrowser; +import org.openaudible.desktop.swt.manager.views.LogWindow; import org.openaudible.desktop.swt.manager.views.Preferences; import org.openaudible.desktop.swt.util.shop.WidgetShop; -import org.openaudible.desktop.swt.manager.views.AboutDialog; -import org.openaudible.desktop.swt.manager.views.LogWindow; /** * The CommandCenter is responsible to react on user-action. User action may for example occur when any item from the main menu is selected. The execute command is the main switch for running commands diff --git a/src/main/java/org/openaudible/desktop/swt/manager/views/BookInfoPanel.java b/src/main/java/org/openaudible/desktop/swt/manager/views/BookInfoPanel.java index 39db5c1..7c09cfe 100644 --- a/src/main/java/org/openaudible/desktop/swt/manager/views/BookInfoPanel.java +++ b/src/main/java/org/openaudible/desktop/swt/manager/views/BookInfoPanel.java @@ -19,9 +19,6 @@ import org.openaudible.desktop.swt.i8n.Translate; import org.openaudible.desktop.swt.manager.AudibleGUI; import org.openaudible.desktop.swt.util.shop.FontShop; import org.openaudible.desktop.swt.util.shop.PaintShop; -import org.openaudible.util.queues.IQueueJob; -import org.openaudible.util.queues.IQueueListener; -import org.openaudible.util.queues.ThreadedQueue; import java.io.File; import java.io.FileInputStream; diff --git a/src/main/java/org/openaudible/desktop/swt/manager/views/FileDropTarget.java b/src/main/java/org/openaudible/desktop/swt/manager/views/FileDropTarget.java index 103dbc0..8f467e6 100644 --- a/src/main/java/org/openaudible/desktop/swt/manager/views/FileDropTarget.java +++ b/src/main/java/org/openaudible/desktop/swt/manager/views/FileDropTarget.java @@ -4,18 +4,10 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.eclipse.swt.dnd.*; import org.eclipse.swt.widgets.Control; -import org.openaudible.Audible; -import org.openaudible.audible.AudibleScraper; -import org.openaudible.convert.AAXParser; -import org.openaudible.desktop.swt.gui.MessageBoxFactory; -import org.openaudible.desktop.swt.gui.SWTAsync; -import org.openaudible.desktop.swt.gui.progress.ProgressDialog; -import org.openaudible.desktop.swt.gui.progress.ProgressTask; import org.openaudible.desktop.swt.manager.AudibleGUI; import java.io.File; import java.util.ArrayList; -import java.util.List; public class FileDropTarget extends DropTargetAdapter diff --git a/src/main/java/org/openaudible/download/DownloadJob.java b/src/main/java/org/openaudible/download/DownloadJob.java index c10ee83..58a6796 100644 --- a/src/main/java/org/openaudible/download/DownloadJob.java +++ b/src/main/java/org/openaudible/download/DownloadJob.java @@ -19,7 +19,6 @@ import org.openaudible.progress.IProgressTask; import org.openaudible.util.CopyWithProgress; import org.openaudible.util.Util; import org.openaudible.util.queues.IQueueJob; -import org.openaudible.util.queues.JobProgress; import java.io.File; import java.io.FileOutputStream; diff --git a/src/main/java/org/openaudible/feeds/pagebuilder/WebPage.java b/src/main/java/org/openaudible/feeds/pagebuilder/WebPage.java index d5118c0..977a60d 100644 --- a/src/main/java/org/openaudible/feeds/pagebuilder/WebPage.java +++ b/src/main/java/org/openaudible/feeds/pagebuilder/WebPage.java @@ -17,7 +17,6 @@ import java.awt.image.BufferedImage; import java.io.File; import java.io.FileWriter; import java.io.IOException; -import java.io.InputStream; import java.util.ArrayList; import java.util.List; diff --git a/src/main/java/org/openaudible/util/Console.java b/src/main/java/org/openaudible/util/Console.java index dcccf21..fd11d4f 100644 --- a/src/main/java/org/openaudible/util/Console.java +++ b/src/main/java/org/openaudible/util/Console.java @@ -15,7 +15,7 @@ public class Console extends ConsoleHandler public interface ILogRecordPublisher { void publish(LogRecord l); - }; + } public final static Console instance = new Console(); boolean installed = false; diff --git a/src/main/java/org/openaudible/util/queues/ThreadedQueue.java b/src/main/java/org/openaudible/util/queues/ThreadedQueue.java index 3f08d65..d9bc8ff 100644 --- a/src/main/java/org/openaudible/util/queues/ThreadedQueue.java +++ b/src/main/java/org/openaudible/util/queues/ThreadedQueue.java @@ -3,7 +3,10 @@ package org.openaudible.util.queues; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import java.util.*; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.LinkedList; public class ThreadedQueue implements IQueueListener { private static final Log LOG = LogFactory.getLog(ThreadedQueue.class);