summaryrefslogtreecommitdiffstats
path: root/models/contentList.php
diff options
context:
space:
mode:
authorraylu <raylu@mixpanel.com>2011-07-02 17:02:07 -0700
committerraylu <raylu@mixpanel.com>2011-07-02 17:02:07 -0700
commit05a2b26d9038752a40348a3f226e44710833c49b (patch)
tree9bc3e49ac2e84b33ca5ff6e44eb7e5f2c02d13bf /models/contentList.php
parent83483a1826d1d05e2f9733746f35fef1939b8c0a (diff)
downloadotakuhub-05a2b26d9038752a40348a3f226e44710833c49b.tar.xz
pull in dev branch changes
not pulled: swiftmailer, gzip
Diffstat (limited to 'models/contentList.php')
-rw-r--r--models/contentList.php87
1 files changed, 87 insertions, 0 deletions
diff --git a/models/contentList.php b/models/contentList.php
index 017e261..ed890ef 100644
--- a/models/contentList.php
+++ b/models/contentList.php
@@ -2,6 +2,10 @@
namespace app\models;
+use app\models\Entry;
+use \phpQuery;
+use \Archive\Tar
+use app\utils\Gzip.php;
class contentList extends \lithium\data\Model {
public function update()
{
@@ -14,4 +18,87 @@ class contentList extends \lithium\data\Model {
$conditions = array('_id' => $user['_id']);
$result = User::update($updateData, $conditions, array('atomic' => false));
}
+
+ public function importManga() {
+
+ }
+
+ public static function importAnimeXML{$user, $file}
+ {
+ $xml = ungzip($file);
+ $list = simplexml_load_string($xml, 'SimpleXMLElement', LIBXML_NOCDATA);
+
+ foreach ($list->animelist as $entry)
+ {
+ $user->animelist[] = Entry::create($entry);
+ }
+
+ return $user->save(null, array('validate' => false));
+ }
+
+ /* public function importAnime($user, $malun, $malpass) {
+ //This method assumes we are importing from mal at the moment.
+
+ //1. Parse Mal for the download link
+ //1.1 Login to MAL
+ $cmd = "curl -c cookie.txt -d \"username=$malun&password=$malpass\" http://myanimelist.net/login.php";
+
+ $result = shell_exec($cmd);
+
+ //If the request went ok
+ if (empty($result)) {
+ //1.2 Request a list export
+ $cmd_getList = "curl -b cookie.txt -d \"value=1&subexport=Export My List\" http://myanimelist.net/panel.php?go=export";
+
+ $malreturn = shell_exec($cmd_getList);
+
+ //Initate a new document for phpQuery.
+ $doc = phpQuery::newDocument($malreturn);
+
+ //Grab the div with the content in it, (should be goodresult actually <div class=goodresult>)
+ $mal = pq('#content');
+
+ //If everything goes to plan, the only link the the body will be the one we want,
+ $link = $mal->find('a')->attr('href');
+
+ $cmd = "curl -b cookie.txt $link";
+
+ $data = shell_exec($cmd);
+
+ $xml_source = gzdecode($data);
+
+ $list = simplexml_load_string($xml_source, 'SimpleXMLElement', LIBXML_NOCDATA);
+
+ foreach($list as $entry) {
+ print_r($entry);
+ }
+
+ }
+
+
+
+ //2. Download the linked file
+
+ //3. Extract and unzip it
+
+ //4. Take the XML and parse it
+ $xml_source; //<-- the XML code
+ $xml = simplexml_load_string($xml_source, 'SimpleXMLElement', LIBXML_NOCDATA);
+
+
+ if (!isset($user->animelist))
+ {
+ $user->animelist = array();
+ }
+
+ //Create entries
+ foreach($xml->anime as $entry)
+ {
+ $user->animelist[] = Entry::create($entry);
+ }
+
+ //Store the entries to the database
+ return $user->save(null, array('validate' => false));
+
+ }*/
} \ No newline at end of file