mirror of
https://github.com/moparisthebest/ComicReader
synced 2024-11-15 13:45:07 -05:00
Added a new RandomIndexedComic + fixed a bug in classes.json and Misfile
This commit is contained in:
parent
562d489a8c
commit
f328f499c0
@ -131,7 +131,7 @@
|
||||
{"class":"GoComics.BroomHilda", "name":"Broom Hilda", "pref":"broomhildaPref"},
|
||||
{"class":"GoComics.TheBuckets", "name":"The Buckets", "pref":"thebucketsPref"},
|
||||
{"class":"GoComics.Buni", "name":"Buni", "pref":"buniPref"},
|
||||
{"class":"GoComics.CaféconLeche", "name":"Café con Leche", "pref":"cafeconlechePref"},
|
||||
{"class":"GoComics.CafeconLeche", "name":"Cafe con Leche", "pref":"cafeconlechePref"},
|
||||
{"class":"GoComics.CalvinandHobbes", "name":"Calvin and Hobbes", "pref":"calvinandhobbesPref"},
|
||||
{"class":"GoComics.Candorville", "name":"Candorville", "pref":"candorvillePref"},
|
||||
{"class":"GoComics.Cathy", "name":"Cathy", "pref":"cathyPref"},
|
||||
|
@ -2,36 +2,63 @@ package com.blogspot.applications4android.comicreader.comics;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import com.blogspot.applications4android.comicreader.comictypes.IndexedComic;
|
||||
import com.blogspot.applications4android.comicreader.core.Downloader;
|
||||
import com.blogspot.applications4android.comicreader.comictypes.RandomIndexedComic;
|
||||
import com.blogspot.applications4android.comicreader.core.Strip;
|
||||
import com.blogspot.applications4android.comicreader.exceptions.ComicLatestException;
|
||||
|
||||
|
||||
public class Cyanide extends IndexedComic {
|
||||
private int mNextId = -1;
|
||||
private int mPrevId = -1;
|
||||
private static final String RAND_URL = "http://www.explosm.net/comics/random/";
|
||||
private static final String[] DONT_CACHE = new String[]{RAND_URL};
|
||||
|
||||
public class Cyanide extends RandomIndexedComic {
|
||||
|
||||
@Override
|
||||
protected String getFrontPageUrl() {
|
||||
return "http://www.explosm.net/comics/";
|
||||
protected int getFirstId() {
|
||||
return 15;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getComicWebPageUrl() {
|
||||
return "http://www.explosm.net/";
|
||||
protected String getRandUrl() {
|
||||
return "http://www.explosm.net/comics/random/";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int parseForLatestId(BufferedReader reader) throws IOException, ComicLatestException {
|
||||
protected int getNextStripId(BufferedReader br, String url) {
|
||||
int id = -1;
|
||||
try {
|
||||
String str;
|
||||
String final_next = null;
|
||||
while ((str = br.readLine()) != null) {
|
||||
if(str.indexOf("case 39") != -1) {
|
||||
final_next = br.readLine();
|
||||
}
|
||||
}
|
||||
setNextId(parseForNextId(final_next, getLatestId()));
|
||||
}
|
||||
catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getPreviousStripId(BufferedReader br, String url) {
|
||||
int id = -1;
|
||||
try {
|
||||
String str;
|
||||
String final_prev = null;
|
||||
while ((str = br.readLine()) != null) {
|
||||
if(str.indexOf("case 37") != -1) {
|
||||
final_prev = br.readLine();
|
||||
}
|
||||
}
|
||||
setPreviousId(parseForPrevId(final_prev, getFirstId()));
|
||||
}
|
||||
catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int parseForLatestId(BufferedReader reader) throws ComicLatestException, IOException {
|
||||
String str;
|
||||
String final_str = null;
|
||||
while((str = reader.readLine()) != null) {
|
||||
@ -50,44 +77,6 @@ public class Cyanide extends IndexedComic {
|
||||
return Integer.parseInt(final_str);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getNextStripUrl() {
|
||||
int id = mNextId;
|
||||
if(id < getFirstId()) {
|
||||
try {
|
||||
id = _getNextStripId(new URI(getCurrentStrip().uid()));
|
||||
}
|
||||
catch (URISyntaxException e) { // this should never occur!
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return getStripUrlFromId(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getPreviousStripUrl() {
|
||||
int id = mPrevId;
|
||||
if(id < getFirstId()) {
|
||||
try {
|
||||
id = _getPrevStripId(new URI(getCurrentStrip().uid()));
|
||||
}
|
||||
catch (URISyntaxException e) { // this should never occur!
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return getStripUrlFromId(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getFirstId() {
|
||||
return 15;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getRandomStripUrl() {
|
||||
return RAND_URL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getStripUrlFromId(int num) {
|
||||
return "http://www.explosm.net/comics/" + num;
|
||||
@ -99,14 +88,23 @@ public class Cyanide extends IndexedComic {
|
||||
return Integer.parseInt(str);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getFrontPageUrl() {
|
||||
return "http://www.explosm.net/comics/";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getComicWebPageUrl() {
|
||||
return "http://www.explosm.net/";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean htmlNeeded() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String parse(String url, BufferedReader reader, Strip strip)
|
||||
throws IOException {
|
||||
protected String parse(String url, BufferedReader reader, Strip strip) throws IOException {
|
||||
boolean comic_found = true;
|
||||
String str;
|
||||
String final_str = null;
|
||||
@ -133,111 +131,31 @@ public class Cyanide extends IndexedComic {
|
||||
final_prev = reader.readLine();
|
||||
}
|
||||
}
|
||||
Log.d("CYanide", "comic_found="+comic_found);
|
||||
/*
|
||||
if(!comic_found) {
|
||||
String msg = "Failed to find the comic for URL="+strip.m_comic_url.toExternalForm();
|
||||
ComicNotFoundException cnf = new ComicNotFoundException(msg);
|
||||
throw cnf;
|
||||
}
|
||||
if((final_str == null) || (final_title == null)) {
|
||||
String msg = "Failed to find the stripURL for URL="+strip.m_comic_url.toExternalForm();
|
||||
msg += " final_str="+final_str+" final_title="+final_title;
|
||||
ComicParseException cpe = new ComicParseException(msg);
|
||||
throw cpe;
|
||||
}
|
||||
*/
|
||||
final_str = final_str.replaceAll(".*Cyanide and Happiness, a daily webcomic\" src=\"","");
|
||||
final_str = final_str.replaceAll("\".*","");
|
||||
final_title = final_title.replaceAll(".*<title>","");
|
||||
final_title = final_title.replaceAll(" - Explosm.*","");
|
||||
strip.setTitle(final_title);
|
||||
strip.setText("-NA-");
|
||||
if(final_next != null) {
|
||||
final_next = final_next.replaceAll(".*comics/", "");
|
||||
final_next = final_next.replaceAll("/\".*", "");
|
||||
mNextId = Integer.parseInt(final_next);
|
||||
}
|
||||
else {
|
||||
mNextId = -1;
|
||||
}
|
||||
if(final_prev != null) {
|
||||
final_prev = final_prev.replaceAll(".*comics/", "");
|
||||
final_prev = final_prev.replaceAll("/\".*", "");
|
||||
mPrevId = Integer.parseInt(final_prev);
|
||||
}
|
||||
else {
|
||||
mPrevId = -1;
|
||||
}
|
||||
// set the next and previous comic IDs from the current url's html data
|
||||
setPreviousId(parseForPrevId(final_prev, -1));
|
||||
setNextId(parseForNextId(final_next, -1));
|
||||
return final_str;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String[] urlsNotForCaching() {
|
||||
return DONT_CACHE;
|
||||
protected int parseForPrevId(String line, int def) {
|
||||
if(line == null) {
|
||||
return def;
|
||||
}
|
||||
line = line.replaceAll(".*comics/", "");
|
||||
line = line.replaceAll("/\".*", "");
|
||||
return Integer.parseInt(line);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the next strip id
|
||||
* @param url url from which to parse
|
||||
* @return desired id
|
||||
*/
|
||||
private int _getNextStripId(URI url) {
|
||||
int id = -1;
|
||||
try {
|
||||
BufferedReader reader = Downloader.openConnection(url);
|
||||
String str;
|
||||
String final_next = null;
|
||||
while ((str = reader.readLine()) != null) {
|
||||
if(str.indexOf("case 39") != -1) {
|
||||
final_next = reader.readLine();
|
||||
}
|
||||
}
|
||||
reader.close();
|
||||
if(final_next != null) {
|
||||
final_next = final_next.replaceAll(".*comics/", "");
|
||||
final_next = final_next.replaceAll("/\".*", "");
|
||||
id = Integer.parseInt(final_next);
|
||||
}
|
||||
else {
|
||||
id = mLatestId;
|
||||
}
|
||||
}
|
||||
catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return id;
|
||||
@Override
|
||||
protected int parseForNextId(String line, int def) {
|
||||
return parseForPrevId(line, def);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the previous strip id
|
||||
* @param url url from which to parse
|
||||
* @return desired id
|
||||
*/
|
||||
private int _getPrevStripId(URI url) {
|
||||
int id = -1;
|
||||
try {
|
||||
BufferedReader reader = Downloader.openConnection(url);
|
||||
String str;
|
||||
String final_prev = null;
|
||||
while ((str = reader.readLine()) != null) {
|
||||
if(str.indexOf("case 37") != -1) {
|
||||
final_prev = reader.readLine();
|
||||
}
|
||||
}
|
||||
reader.close();
|
||||
if(final_prev != null) {
|
||||
final_prev = final_prev.replaceAll(".*comics/", "");
|
||||
final_prev = final_prev.replaceAll("/\".*", "");
|
||||
id = Integer.parseInt(final_prev);
|
||||
}
|
||||
else {
|
||||
id = getFirstId();
|
||||
}
|
||||
}
|
||||
catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return id;
|
||||
}
|
||||
}
|
||||
|
@ -44,13 +44,6 @@ public class Misfile extends DailyComic {
|
||||
strip.setTitle("Misfile: " + date);
|
||||
strip.setText("-NA-");
|
||||
return final_str;
|
||||
/*
|
||||
String index = url.replaceAll(".*page=", "");
|
||||
String url_str = "http://www.misfile.com/overlay.php?pageCalled="+index;
|
||||
strip.setTitle("Misfile: " + index);
|
||||
strip.setText("-NA-");
|
||||
return url_str;
|
||||
*/
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -73,7 +66,7 @@ public class Misfile extends DailyComic {
|
||||
String[] elements = date.split("-");
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.set(Calendar.YEAR, Integer.parseInt(elements[0]));
|
||||
cal.set(Calendar.MONTH, Integer.parseInt(elements[1]));
|
||||
cal.set(Calendar.MONTH, Integer.parseInt(elements[1])-1);
|
||||
cal.set(Calendar.DAY_OF_MONTH, Integer.parseInt(elements[2]));
|
||||
return cal;
|
||||
}
|
||||
@ -82,7 +75,7 @@ public class Misfile extends DailyComic {
|
||||
public String getUrlFromTime(Calendar cal) {
|
||||
return String.format("http://www.misfile.com/?date=%04d-%02d-%02d",
|
||||
cal.get(Calendar.YEAR),
|
||||
cal.get(Calendar.MONTH),
|
||||
cal.get(Calendar.MONTH)+1,
|
||||
cal.get(Calendar.DAY_OF_MONTH));
|
||||
}
|
||||
}
|
||||
|
@ -1,92 +1,156 @@
|
||||
package com.blogspot.applications4android.comicreader.comics;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
|
||||
import com.blogspot.applications4android.comicreader.comictypes.IndexedComic;
|
||||
import com.blogspot.applications4android.comicreader.core.Strip;
|
||||
import com.blogspot.applications4android.comicreader.exceptions.ComicLatestException;
|
||||
|
||||
|
||||
public class TheDevilsPanties extends IndexedComic {
|
||||
|
||||
@Override
|
||||
protected String getFrontPageUrl() {
|
||||
return "http://thedevilspanties.com/";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getComicWebPageUrl() {
|
||||
return "http://thedevilspanties.com/";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int parseForLatestId(BufferedReader reader) throws IOException, ComicLatestException {
|
||||
String str;
|
||||
String final_str = null;
|
||||
while((str = reader.readLine()) != null) {
|
||||
int index1 = str.indexOf("comic-id-");
|
||||
if (index1 != -1) {
|
||||
final_str = str;
|
||||
}
|
||||
}
|
||||
if(final_str == null) {
|
||||
String msg = "Failed to get the latest id for "+this.getClass().getSimpleName();
|
||||
ComicLatestException e = new ComicLatestException(msg);
|
||||
throw e;
|
||||
}
|
||||
final_str = final_str.replaceAll(".*comic-id-","");
|
||||
final_str = final_str.replaceAll("\".*","");
|
||||
return Integer.parseInt(final_str);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getStripUrlFromId(int num) {
|
||||
return "http://thedevilspanties.com/archives/" + num;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getIdFromStripUrl(String url) {
|
||||
return Integer.parseInt(url.replaceAll("http.*archives/", ""));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean htmlNeeded() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected String parse(String url, BufferedReader reader, Strip strip)
|
||||
throws IOException {
|
||||
String str;
|
||||
String final_str = null;
|
||||
String final_title = null;
|
||||
while ((str = reader.readLine()) != null) {
|
||||
int index1 = str.indexOf("comicpane");
|
||||
if (index1 != -1) {
|
||||
final_str = str;
|
||||
final_title = str;
|
||||
}
|
||||
}
|
||||
/*
|
||||
if((final_str == null) || (final_title == null)) {
|
||||
String msg = "Failed to find the comic for URL="+url;
|
||||
ComicNotFoundException cnf = new ComicNotFoundException(msg);
|
||||
throw cnf;
|
||||
}
|
||||
*/
|
||||
final_str = final_str.replaceAll(".*src=\"","");
|
||||
final_str = final_str.replaceAll("\".*","");
|
||||
final_title = final_title.replaceAll(".*alt=\"","");
|
||||
final_title = final_title.replaceAll("\".*","");
|
||||
strip.setTitle("The Devils Panties: "+final_title);
|
||||
strip.setText("-NA-");
|
||||
return final_str;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getFirstId() {
|
||||
return 300;
|
||||
}
|
||||
}
|
||||
package com.blogspot.applications4android.comicreader.comics;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
|
||||
import com.blogspot.applications4android.comicreader.comictypes.RandomIndexedComic;
|
||||
import com.blogspot.applications4android.comicreader.core.Strip;
|
||||
import com.blogspot.applications4android.comicreader.exceptions.ComicLatestException;
|
||||
|
||||
public class TheDevilsPanties extends RandomIndexedComic {
|
||||
|
||||
@Override
|
||||
protected String getRandUrl() {
|
||||
return getStripUrlFromId(getFirstId());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getNextStripId(BufferedReader br, String url) {
|
||||
int id = -1;
|
||||
try {
|
||||
String str;
|
||||
String final_next = null;
|
||||
while ((str = br.readLine()) != null) {
|
||||
if(str.indexOf("navi navi-next") != -1) {
|
||||
final_next = str;
|
||||
}
|
||||
}
|
||||
setNextId(parseForNextId(final_next, getLatestId()));
|
||||
}
|
||||
catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getPreviousStripId(BufferedReader br, String url) {
|
||||
int id = -1;
|
||||
try {
|
||||
String str;
|
||||
String final_prev = null;
|
||||
while ((str = br.readLine()) != null) {
|
||||
if(str.indexOf("navi navi-prev") != -1) {
|
||||
final_prev = str;
|
||||
}
|
||||
}
|
||||
setPreviousId(parseForPrevId(final_prev, getFirstId()));
|
||||
}
|
||||
catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int parseForLatestId(BufferedReader reader) throws ComicLatestException, IOException {
|
||||
String str;
|
||||
String final_str = null;
|
||||
while((str = reader.readLine()) != null) {
|
||||
int index1 = str.indexOf("comic-id-");
|
||||
if (index1 != -1) {
|
||||
final_str = str;
|
||||
}
|
||||
}
|
||||
if(final_str == null) {
|
||||
String msg = "Failed to get the latest id for "+this.getClass().getSimpleName();
|
||||
ComicLatestException e = new ComicLatestException(msg);
|
||||
throw e;
|
||||
}
|
||||
final_str = final_str.replaceAll(".*comic-id-","");
|
||||
final_str = final_str.replaceAll("\".*","");
|
||||
return Integer.parseInt(final_str);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getStripUrlFromId(int num) {
|
||||
return "http://thedevilspanties.com/archives/" + num;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getIdFromStripUrl(String url) {
|
||||
return Integer.parseInt(url.replaceAll("http.*archives/", ""));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getFrontPageUrl() {
|
||||
return "http://thedevilspanties.com/";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getComicWebPageUrl() {
|
||||
return "http://thedevilspanties.com/";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean htmlNeeded() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String parse(String url, BufferedReader reader, Strip strip) throws IOException {
|
||||
String str;
|
||||
String final_str = null;
|
||||
String final_title = null;
|
||||
String final_next = null;
|
||||
String final_prev = null;
|
||||
while((str = reader.readLine()) != null) {
|
||||
if(str.indexOf("comicpane") != -1) {
|
||||
final_str = str;
|
||||
final_title = str;
|
||||
}
|
||||
else if(str.indexOf("navi navi-prev") != -1) {
|
||||
final_prev = str;
|
||||
}
|
||||
else if(str.indexOf("navi navi-next") != -1) {
|
||||
final_next = str;
|
||||
}
|
||||
}
|
||||
final_str = final_str.replaceAll(".*src=\"","");
|
||||
final_str = final_str.replaceAll("\".*","");
|
||||
final_title = final_title.replaceAll(".*alt=\"","");
|
||||
final_title = final_title.replaceAll("\".*","");
|
||||
strip.setTitle("The Devils Panties: "+final_title);
|
||||
strip.setText("-NA-");
|
||||
// set the next and previous comic IDs from the current url's html data
|
||||
setNextId(parseForNextId(final_next, -1));
|
||||
setPreviousId(parseForPrevId(final_prev, -1));
|
||||
return final_str;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getFirstId() {
|
||||
return 300;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int parseForPrevId(String line, int def) {
|
||||
if(line == null) {
|
||||
return def;
|
||||
}
|
||||
line = line.replaceAll(".*href=\"", "");
|
||||
line = line.replaceAll("\".*", "");
|
||||
line = line.replaceAll("/archives/", "");
|
||||
try {
|
||||
return Integer.parseInt(line);
|
||||
}
|
||||
catch(Exception e) {
|
||||
return def;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int parseForNextId(String line, int def) {
|
||||
return parseForPrevId(line, def);
|
||||
}
|
||||
}
|
||||
|
@ -55,7 +55,8 @@ public class ComicClassList {
|
||||
//// NOTE NOTE NOTE NOTE ////
|
||||
/// Before releasing to market, do remember to set the below flag to 'true'!!!!!!!!
|
||||
/** flag which will tell whether to use the below array to filtering the comics! */
|
||||
private static boolean FILTER_COMICS = true;
|
||||
private static boolean FILTER_COMICS = false;
|
||||
|
||||
/** list of comics that cannot be shown to the users! */
|
||||
private static final String[] FILTER_COMICS_LIST = { "Cyanide and Happiness" };
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user