2014-02-25 10:28:22 +01:00
|
|
|
package com.rarchives.ripme.ripper;
|
|
|
|
|
2014-02-26 08:44:22 +01:00
|
|
|
import java.io.File;
|
|
|
|
import java.io.IOException;
|
2014-02-25 10:28:22 +01:00
|
|
|
import java.net.MalformedURLException;
|
|
|
|
import java.net.URL;
|
|
|
|
|
2014-02-26 08:44:22 +01:00
|
|
|
import com.rarchives.ripme.utils.Utils;
|
|
|
|
|
2014-02-25 10:28:22 +01:00
|
|
|
public abstract class AbstractRipper implements RipperInterface {
|
|
|
|
|
|
|
|
protected URL url;
|
2014-02-26 08:44:22 +01:00
|
|
|
protected File workingDir = null;
|
|
|
|
|
|
|
|
public abstract void rip() throws IOException;
|
|
|
|
public abstract void setWorkingDir() throws IOException;
|
2014-02-25 10:28:22 +01:00
|
|
|
|
2014-02-26 08:44:22 +01:00
|
|
|
/**
|
|
|
|
* Ensures inheriting ripper can rip this URL.
|
|
|
|
* @param url
|
|
|
|
* URL to rip.
|
|
|
|
* @throws IOException
|
|
|
|
* If anything goes wrong.
|
|
|
|
*/
|
|
|
|
public AbstractRipper(URL url) throws IOException {
|
2014-02-25 10:28:22 +01:00
|
|
|
if (!canRip(url)) {
|
|
|
|
throw new MalformedURLException("Unable to rip url: " + url);
|
|
|
|
}
|
|
|
|
this.url = url;
|
2014-02-26 08:44:22 +01:00
|
|
|
setWorkingDir();
|
|
|
|
workingDir = Utils.getWorkingDirectory();
|
2014-02-25 10:28:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public URL getURL() {
|
|
|
|
return url;
|
|
|
|
}
|
|
|
|
|
2014-02-26 08:44:22 +01:00
|
|
|
}
|