|
@@ 926-993 (lines=68) @@
|
| 923 |
|
} |
| 924 |
|
} |
| 925 |
|
|
| 926 |
|
class SeaOtterScans extends Site_Model { |
| 927 |
|
public function getFullTitleURL(string $title_url) : string { |
| 928 |
|
return "http://reader.seaotterscans.com/series/{$title_url}"; |
| 929 |
|
} |
| 930 |
|
|
| 931 |
|
public function isValidTitleURL(string $title_url) : bool { |
| 932 |
|
$success = (bool) preg_match('/^[a-z0-9_]+/', $title_url); |
| 933 |
|
if(!$success) log_message('error', "Invalid Title URL (SeaOtterScans): {$title_url}"); |
| 934 |
|
return $success; |
| 935 |
|
} |
| 936 |
|
public function isValidChapter(string $chapter) : bool { |
| 937 |
|
$success = (bool) preg_match('/^en\/[0-9]+(?:\/[0-9]+(?:\/[0-9]+(?:\/[0-9]+)?)?)?$/', $chapter); |
| 938 |
|
if(!$success) log_message('error', 'Invalid Chapter (SeaOtterScans): '.$chapter); |
| 939 |
|
return $success; |
| 940 |
|
} |
| 941 |
|
|
| 942 |
|
public function getChapterData(string $title_url, string $chapter) : array { |
| 943 |
|
//LANG/VOLUME/CHAPTER/CHAPTER_EXTRA(/page/) |
| 944 |
|
$chapter_parts = explode('/', $chapter); |
| 945 |
|
return [ |
| 946 |
|
'url' => "https://reader.seaotterscans.com/read/{$title_url}/{$chapter}/", |
| 947 |
|
'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '') . "c{$chapter_parts[2]}" . (isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/ |
| 948 |
|
]; |
| 949 |
|
} |
| 950 |
|
|
| 951 |
|
public function getTitleData(string $title_url) { |
| 952 |
|
$titleData = []; |
| 953 |
|
|
| 954 |
|
$fullURL = $this->getFullTitleURL($title_url); |
| 955 |
|
|
| 956 |
|
$content = $this->get_content($fullURL); |
| 957 |
|
$data = $content['body']; |
| 958 |
|
if(strpos($data, '404 Page Not Found') === FALSE) { |
| 959 |
|
//FIXME: For whatever reason, we can't grab the entire div without simplexml shouting at us |
| 960 |
|
$data = preg_replace('/^[\S\s]*(<article[\S\s]*)<\/article>[\S\s]*$/', '$1', $data); |
| 961 |
|
|
| 962 |
|
$dom = new DOMDocument(); |
| 963 |
|
libxml_use_internal_errors(true); |
| 964 |
|
$dom->loadHTML($data); |
| 965 |
|
libxml_use_internal_errors(false); |
| 966 |
|
|
| 967 |
|
$xpath = new DOMXPath($dom); |
| 968 |
|
|
| 969 |
|
$nodes_title = $xpath->query("//div[@class='large comic']/h1[@class='title']"); |
| 970 |
|
|
| 971 |
|
//SOO sometimes uses volume groups which are above recent chapters (if they haven't been grouped yet), so make sure we check for both. |
| 972 |
|
$nodes_row = $xpath->query("//div[@class='list']/div[@class='group']/div[@class='title' and text() = 'Chapters']/following-sibling::div[@class='element'][1]"); |
| 973 |
|
if($nodes_row->length !== 1) { |
| 974 |
|
$nodes_row = $xpath->query("//div[@class='list']/div[@class='group'][1]/div[@class='element'][1]"); |
| 975 |
|
} |
| 976 |
|
if($nodes_title->length === 1 && $nodes_row->length === 1) { |
| 977 |
|
$titleData['title'] = trim($nodes_title->item(0)->textContent); |
| 978 |
|
|
| 979 |
|
$firstRow = $nodes_row->item(0); |
| 980 |
|
$nodes_latest = $xpath->query("div[@class='meta_r']", $firstRow); |
| 981 |
|
$nodes_chapter = $xpath->query("div[@class='title']/a", $firstRow); |
| 982 |
|
|
| 983 |
|
$link = (string) $nodes_chapter->item(0)->getAttribute('href'); |
| 984 |
|
$titleData['latest_chapter'] = preg_replace('/.*\/read\/.*?\/(.*?)\/$/', '$1', $link); |
| 985 |
|
$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime((string) str_replace('.', '', explode(',', $nodes_latest[0]->textContent)[1]))); |
| 986 |
|
} |
| 987 |
|
} else { |
| 988 |
|
//TODO: Throw ERRORS; |
| 989 |
|
} |
| 990 |
|
|
| 991 |
|
return (!empty($titleData) ? $titleData : NULL); |
| 992 |
|
} |
| 993 |
|
} |
| 994 |
|
|
| 995 |
|
class HelveticaScans extends Site_Model { |
| 996 |
|
public function getFullTitleURL(string $title_url) : string { |
|
@@ 995-1060 (lines=66) @@
|
| 992 |
|
} |
| 993 |
|
} |
| 994 |
|
|
| 995 |
|
class HelveticaScans extends Site_Model { |
| 996 |
|
public function getFullTitleURL(string $title_url) : string { |
| 997 |
|
return "http://helveticascans.com/reader/series/{$title_url}"; |
| 998 |
|
} |
| 999 |
|
|
| 1000 |
|
public function isValidTitleURL(string $title_url) : bool { |
| 1001 |
|
$success = (bool) preg_match('/^[a-z0-9_]+/', $title_url); |
| 1002 |
|
if(!$success) log_message('error', "Invalid Title URL (HelveticaScans): {$title_url}"); |
| 1003 |
|
return $success; |
| 1004 |
|
} |
| 1005 |
|
public function isValidChapter(string $chapter) : bool { |
| 1006 |
|
$success = (bool) preg_match('/^en\/[0-9]+(?:\/[0-9]+(?:\/[0-9]+(?:\/[0-9]+)?)?)?$/', $chapter); |
| 1007 |
|
if(!$success) log_message('error', 'Invalid Chapter (HelveticaScans): '.$chapter); |
| 1008 |
|
return $success; |
| 1009 |
|
} |
| 1010 |
|
|
| 1011 |
|
public function getChapterData(string $title_url, string $chapter) : array { |
| 1012 |
|
//LANG/VOLUME/CHAPTER/CHAPTER_EXTRA(/page/) |
| 1013 |
|
$chapter_parts = explode('/', $chapter); |
| 1014 |
|
return [ |
| 1015 |
|
'url' => "http://helveticascans.com/reader/read/{$title_url}/{$chapter}/", |
| 1016 |
|
'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '') . "c{$chapter_parts[2]}" . (isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/ |
| 1017 |
|
]; |
| 1018 |
|
} |
| 1019 |
|
|
| 1020 |
|
public function getTitleData(string $title_url) { |
| 1021 |
|
$titleData = []; |
| 1022 |
|
|
| 1023 |
|
$fullURL = $this->getFullTitleURL($title_url); |
| 1024 |
|
|
| 1025 |
|
$content = $this->get_content($fullURL); |
| 1026 |
|
$data = $content['body']; |
| 1027 |
|
if(strpos($data, '404 Page Not Found') === FALSE) { |
| 1028 |
|
//FIXME: For whatever reason, we can't grab the entire div without simplexml shouting at us |
| 1029 |
|
$data = preg_replace('/^[\S\s]*(<article[\S\s]*)<\/article>[\S\s]*$/', '$1', $data); |
| 1030 |
|
|
| 1031 |
|
$dom = new DOMDocument(); |
| 1032 |
|
libxml_use_internal_errors(true); |
| 1033 |
|
$dom->loadHTML($data); |
| 1034 |
|
libxml_use_internal_errors(false); |
| 1035 |
|
|
| 1036 |
|
$xpath = new DOMXPath($dom); |
| 1037 |
|
|
| 1038 |
|
$nodes_title = $xpath->query("//div[@class='large comic']/h1[@class='title']"); |
| 1039 |
|
$nodes_row = $xpath->query("//div[@class='list']/div[@class='group']/div[@class='title' and text() = 'Chapters']/following-sibling::div[@class='element'][1]"); |
| 1040 |
|
if($nodes_row->length !== 1) { |
| 1041 |
|
$nodes_row = $xpath->query("//div[@class='list']/div[@class='group'][1]/div[@class='element'][1]"); |
| 1042 |
|
} |
| 1043 |
|
if($nodes_title->length === 1 && $nodes_row->length === 1) { |
| 1044 |
|
$titleData['title'] = trim($nodes_title->item(0)->textContent); |
| 1045 |
|
|
| 1046 |
|
|
| 1047 |
|
$nodes_latest = $xpath->query("div[@class='meta_r']", $nodes_row[0]); |
| 1048 |
|
$nodes_chapter = $xpath->query("div[@class='title']/a", $nodes_row[0]); |
| 1049 |
|
|
| 1050 |
|
$link = (string) $nodes_chapter->item(0)->getAttribute('href'); |
| 1051 |
|
$titleData['latest_chapter'] = preg_replace('/.*\/read\/.*?\/(.*?)\/$/', '$1', $link); |
| 1052 |
|
$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime((string) str_replace('.', '', explode(',', $nodes_latest->item(0)->textContent)[1]))); |
| 1053 |
|
} |
| 1054 |
|
} else { |
| 1055 |
|
//TODO: Throw ERRORS; |
| 1056 |
|
} |
| 1057 |
|
|
| 1058 |
|
return (!empty($titleData) ? $titleData : NULL); |
| 1059 |
|
} |
| 1060 |
|
} |
| 1061 |
|
|
| 1062 |
|
class SenseScans extends Site_Model { |
| 1063 |
|
public function getFullTitleURL(string $title_url) : string { |
|
@@ 1062-1126 (lines=65) @@
|
| 1059 |
|
} |
| 1060 |
|
} |
| 1061 |
|
|
| 1062 |
|
class SenseScans extends Site_Model { |
| 1063 |
|
public function getFullTitleURL(string $title_url) : string { |
| 1064 |
|
return "http://reader.sensescans.com/series/{$title_url}"; |
| 1065 |
|
} |
| 1066 |
|
|
| 1067 |
|
public function isValidTitleURL(string $title_url) : bool { |
| 1068 |
|
$success = (bool) preg_match('/^[a-z0-9_]+/', $title_url); |
| 1069 |
|
if(!$success) log_message('error', "Invalid Title URL (SenseScans): {$title_url}"); |
| 1070 |
|
return $success; |
| 1071 |
|
} |
| 1072 |
|
public function isValidChapter(string $chapter) : bool { |
| 1073 |
|
$success = (bool) preg_match('/^en\/[0-9]+(?:\/[0-9]+(?:\/[0-9]+(?:\/[0-9]+)?)?)?$/', $chapter); |
| 1074 |
|
if(!$success) log_message('error', 'Invalid Chapter (SenseScans): '.$chapter); |
| 1075 |
|
return $success; |
| 1076 |
|
} |
| 1077 |
|
|
| 1078 |
|
public function getChapterData(string $title_url, string $chapter) : array { |
| 1079 |
|
//LANG/VOLUME/CHAPTER/CHAPTER_EXTRA(/page/) |
| 1080 |
|
$chapter_parts = explode('/', $chapter); |
| 1081 |
|
return [ |
| 1082 |
|
'url' => "http://reader.sensescans.com/read/{$title_url}/{$chapter}/", |
| 1083 |
|
'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '') . "c{$chapter_parts[2]}" . (isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/ |
| 1084 |
|
]; |
| 1085 |
|
} |
| 1086 |
|
|
| 1087 |
|
public function getTitleData(string $title_url) { |
| 1088 |
|
$titleData = []; |
| 1089 |
|
|
| 1090 |
|
$fullURL = $this->getFullTitleURL($title_url); |
| 1091 |
|
|
| 1092 |
|
$content = $this->get_content($fullURL); |
| 1093 |
|
$data = $content['body']; |
| 1094 |
|
if(strpos($data, '404 Page Not Found') === FALSE) { |
| 1095 |
|
//FIXME: For whatever reason, we can't grab the entire div without simplexml shouting at us |
| 1096 |
|
$data = preg_replace('/^[\S\s]*(<article[\S\s]*)<\/article>[\S\s]*$/', '$1', $data); |
| 1097 |
|
|
| 1098 |
|
$dom = new DOMDocument(); |
| 1099 |
|
libxml_use_internal_errors(true); |
| 1100 |
|
$dom->loadHTML($data); |
| 1101 |
|
libxml_use_internal_errors(false); |
| 1102 |
|
|
| 1103 |
|
$xpath = new DOMXPath($dom); |
| 1104 |
|
|
| 1105 |
|
$nodes_title = $xpath->query("//div[@class='large comic']/h1[@class='title']"); |
| 1106 |
|
$nodes_row = $xpath->query("//div[@class='list']/div[@class='group']/div[@class='title' and text() = 'Chapters']/following-sibling::div[@class='element'][1]"); |
| 1107 |
|
if($nodes_row->length !== 1) { |
| 1108 |
|
$nodes_row = $xpath->query("//div[@class='list']/div[@class='group'][1]/div[@class='element'][1]"); |
| 1109 |
|
} |
| 1110 |
|
if($nodes_title->length === 1 && $nodes_row->length === 1) { |
| 1111 |
|
$titleData['title'] = trim($nodes_title->item(0)->textContent); |
| 1112 |
|
|
| 1113 |
|
$nodes_latest = $xpath->query("div[@class='meta_r']", $nodes_row[0]); |
| 1114 |
|
$nodes_chapter = $xpath->query("div[@class='title']/a", $nodes_row[0]); |
| 1115 |
|
|
| 1116 |
|
$link = (string) $nodes_chapter->item(0)->getAttribute('href'); |
| 1117 |
|
$titleData['latest_chapter'] = preg_replace('/.*\/read\/.*?\/(.*?)\/$/', '$1', $link); |
| 1118 |
|
$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime((string) str_replace('.', '', explode(',', $nodes_latest->item(0)->textContent)[1]))); |
| 1119 |
|
} |
| 1120 |
|
} else { |
| 1121 |
|
//TODO: Throw ERRORS; |
| 1122 |
|
} |
| 1123 |
|
|
| 1124 |
|
return (!empty($titleData) ? $titleData : NULL); |
| 1125 |
|
} |
| 1126 |
|
} |
| 1127 |
|
|