private static function parseManga($item)
 {
     $crawler = new Crawler($item);
     $manga = new Manga();
     $manga->setId($crawler->filter('id')->text());
     $manga->setTitle($crawler->filter('title')->text());
     $otherTitles = array();
     $english = explode('; ', $crawler->filter('english')->text());
     if (count($english) > 0 && $english !== '') {
         $otherTitles['english'] = $english;
     }
     $synonyms = explode('; ', $crawler->filter('synonyms')->text());
     if (count($synonyms) > 0 && $synonyms[0] !== '') {
         $otherTitles['synonyms'] = $synonyms;
     }
     $manga->setOtherTitles($otherTitles);
     $manga->setOtherTitles($otherTitles);
     $manga->setChapters($crawler->filter('chapters')->text());
     $manga->setVolumes($crawler->filter('volumes')->text());
     $manga->setMembersScore($crawler->filter('score')->text());
     $manga->setStatus($crawler->filter('status')->text());
     $startDate = $crawler->filter('start_date')->text();
     if ($startDate !== '0000-00-00') {
         $manga->setStartDate((new \DateTime())->createFromFormat('Y-m-d', $startDate));
     }
     $EndDate = $crawler->filter('end_date')->text();
     if ($EndDate !== '0000-00-00') {
         $manga->setEndDate((new \DateTime())->createFromFormat('Y-m-d', $EndDate));
     }
     $manga->setSynopsis($crawler->filter('synopsis')->text());
     $manga->setImageUrl($crawler->filter('image')->text());
     return $manga;
 }
 /**
  * Update a manga on a user's list.
  *
  * Uses the contents of the HTTP Request to get the needed data for updating the
  * requested title. The user must have passed the basic authentication needs and the
  * PHP_AUTH_USER and PHP_AUTH_PW variables must be set. If so, the get variables of
  * "status", "chapters", "volumes", and "score" are checked and used in the creation
  * of a manga object. The object is used to make an XML document that is then posted
  * to MyAnimeList.
  *
  * @param Request $request Contains all the needed information to update the title.
  * @param int     $id      ID of the manga.
  *
  * @return View
  */
 public function updateAction(Request $request, $id, $apiVersion)
 {
     // http://mymangalist.net/api/mangalist/update/#{id}.xml
     //get the credentials we received
     $username = $this->getRequest()->server->get('PHP_AUTH_USER');
     $password = $this->getRequest()->server->get('PHP_AUTH_PW');
     //Don't bother making a request if the user didn't send any authentication
     if ($username === null) {
         $view = $this->view(array('error' => 'unauthorized'), 401);
         $view->setHeader('WWW-Authenticate', 'Basic realm="myanimelist.net"');
         return $view;
     }
     $manga = new Manga();
     $manga->setId($id);
     //Only use values we were sent for the Update XML
     $update_items = array();
     try {
         if ($request->request->get('status') !== null) {
             $manga->setReadStatus($request->request->get('status'));
             $update_items[] = 'status';
         }
         if ($request->request->get('chapters') !== null) {
             $manga->setChaptersRead($request->request->get('chapters'));
             $update_items[] = 'chapters';
         }
         if ($request->request->get('volumes') !== null) {
             $manga->setVolumesRead($request->request->get('volumes'));
             $update_items[] = 'volumes';
         }
         if ($request->request->get('score') !== null) {
             $manga->setScore($request->request->get('score'));
             $update_items[] = 'score';
         }
         //API 2 Items
         if ($apiVersion >= 2.0) {
             if ($request->request->get('downloaded_chap') !== null) {
                 $manga->setChapDownloaded($request->request->get('downloaded_chap'));
                 //Int
                 $update_items[] = 'downloaded';
             }
             if ($request->request->get('reread_count') !== null) {
                 $manga->setRereadCount($request->request->get('reread_count'));
                 //Int
                 $update_items[] = 'rereadCount';
             }
             if ($request->request->get('reread_value') !== null) {
                 $manga->setRereadValue($request->request->get('reread_value'));
                 //Int
                 $update_items[] = 'rereadValue';
             }
             if ($request->request->get('start') !== null) {
                 $manga->setReadingStart(DateTime::createFromFormat('Y-m-d', $request->request->get('start')));
                 //Needs to be DT!
                 $update_items[] = 'start';
             }
             if ($request->request->get('end') !== null) {
                 $manga->setReadingEnd(DateTime::createFromFormat('Y-m-d', $request->request->get('end')));
                 //Needs to be DT!
                 $update_items[] = 'end';
             }
             if ($request->request->get('priority') !== null) {
                 $manga->setPriority($request->request->get('priority'));
                 $update_items[] = 'priority';
             }
             if ($request->request->get('is_rereading') !== null) {
                 $manga->setRereading($request->request->get('is_rereading'));
                 //Bool - 0 = no, 1 = yes
                 $update_items[] = 'isRereading';
             }
             if ($request->request->get('comments') !== null) {
                 $manga->setPersonalComments($request->request->get('comments'));
                 //Plain text string. No HTML.
                 $update_items[] = 'comments';
             }
             if ($request->request->get('tags') !== null) {
                 $manga->setPersonalTags($request->request->get('tags'));
                 //Comma-separated string
                 $update_items[] = 'tags';
             }
         }
     } catch (\Exception $e) {
         return $this->view(array('error' => $e->getMessage()), 500);
     }
     $xmlcontent = $manga->MALApiXml($update_items);
     $connection = $this->get('atarashii_api.communicator');
     try {
         $connection->sendXML('/api/mangalist/update/' . $manga->getId() . '.xml', $xmlcontent, $username, $password);
         return $this->view('ok', 200);
     } catch (Exception\ClientErrorResponseException $e) {
         $view = $this->view(array('error' => 'unauthorized'), 401);
         $view->setHeader('WWW-Authenticate', 'Basic realm="myanimelist.net"');
         return $view;
     } catch (Exception\ServerErrorResponseException $e) {
         //MAL broke API responses, so we have to check the content on the response to make sure
         //it actually was an error.
         $response = $e->getResponse()->getBody(true);
         if (stripos($response, 'Updated') === 0) {
             return $this->view('ok', 200);
         }
         return $this->view(array('error' => 'not-found'), 404);
     } catch (Exception\CurlException $e) {
         return $this->view(array('error' => 'network-error'), 500);
     }
 }
 /**
  * @param         $apiVersion  The API version of the request
  * @param         $requestType The anime or manga request string
  * @param Request $request     HTTP Request object
  *
  * @return \FOS\RestBundle\View\View
  */
 public function getBrowseAction($apiVersion, $requestType, Request $request)
 {
     $downloader = $this->get('atarashii_api.communicator');
     $page = (int) $request->query->get('page');
     if ($page <= 0) {
         $page = 1;
     }
     // Create URL parts supported by MAL
     $pagePart = '&show=' . ($page * 50 - 50);
     $keyword = '&q=' . $request->query->get('keyword');
     $score = '&score=' . (int) $request->query->get('score');
     $reverse = '&w=' . (int) $request->query->get('reverse');
     $rating = '&r=' . (int) $request->query->get('rating');
     $genreType = '&gx=' . (int) $request->query->get('genre_type');
     $status = '&status=' . $this->getStatusId($request->query->get('status'));
     $endDateArray = explode('-', $request->query->get('end_date'));
     if (count($endDateArray) == 3) {
         $endDate = '&ey=' . $endDateArray[0] . '&em=' . $endDateArray[1] . '&ed=' . $endDateArray[2];
     } else {
         $endDate = '';
     }
     $startDateArray = explode('-', $request->query->get('start_date'));
     if (count($startDateArray) == 3) {
         $startDate = '&sy=' . $startDateArray[0] . '&sm=' . $startDateArray[1] . '&sd=' . $startDateArray[2];
     } else {
         $startDate = '';
     }
     if ($requestType === 'anime') {
         $type = '&type=' . Anime::getTypeId($request->query->get('type'));
         $genres = Anime::getGenresId($request->query->get('genres'));
         $sort = '&o=' . Anime::getColumnId($request->query->get('sort'), $requestType);
     } else {
         $type = '&type=' . Manga::getTypeId($request->query->get('type'));
         $genres = Manga::getGenresId($request->query->get('genres'));
         $sort = '&o=' . Manga::getColumnId($request->query->get('sort'), $requestType);
     }
     // Combine all URL parts for the request
     $url = $genres . $sort . $reverse . $endDate . $startDate . $rating . $status . $type . $keyword . $score . $genreType . $pagePart;
     try {
         $content = $downloader->fetch('/' . $requestType . '.php?c[]=a&c[]=b&c[]=c&c[]=d&c[]=e&c[]=f&c[]=g&c[]=g' . $url);
     } catch (Exception\CurlException $e) {
         return $this->view(array('error' => 'network-error'), 500);
     } catch (Exception\ClientErrorResponseException $e) {
         $content = $e->getResponse();
     }
     $response = new Response();
     $serializationContext = SerializationContext::create();
     $serializationContext->setVersion($apiVersion);
     $response->setPublic();
     $response->setMaxAge(86400);
     //One day
     $response->headers->addCacheControlDirective('must-revalidate', true);
     $response->setEtag($type . '/' . $requestType . '?' . $url);
     //Also, set "expires" header for caches that don't understand Cache-Control
     $date = new \DateTime();
     $date->modify('+86400 seconds');
     //One day
     $response->setExpires($date);
     // MAL does contain a bug where excluded genres allow the same amount of pages as normal without warning
     // To avoid issues we check if the page number does match the content page number.
     preg_match('/>\\[(\\d+?)\\]/', $content, $matches);
     if (strpos($content, 'No titles that matched') !== false || strpos($content, 'This page doesn\'t exist') !== false) {
         return $this->view(array('error' => 'not-found'), 404);
     } else {
         if (count($matches) > 1 && (int) $matches[1] !== $page) {
             return $this->view(array(), 200);
         } else {
             //MAL now returns 404 on a single result. Workaround
             if (method_exists($content, 'getStatusCode') && $content->getStatusCode() === 404) {
                 $location = $content->getHeader('Location');
                 try {
                     $content = $downloader->fetch($location);
                     if ($type === 'anime') {
                         $searchResult = array(AnimeParser::parse($content));
                     } else {
                         $searchResult = array(MangaParser::parse($content));
                     }
                 } catch (Exception\CurlException $e) {
                     return $this->view(array('error' => 'network-error'), 500);
                 }
             } else {
                 if ($downloader->wasRedirected()) {
                     if ($type === 'anime') {
                         $searchResult = array(AnimeParser::parse($content));
                     } else {
                         $searchResult = array(MangaParser::parse($content));
                     }
                 } else {
                     $searchResult = Upcoming::parse($content, $requestType);
                 }
             }
             $view = $this->view($searchResult);
             $view->setSerializationContext($serializationContext);
             $view->setResponse($response);
             $view->setStatusCode(200);
             return $view;
         }
     }
 }
示例#4
0
 private static function parseRecord($item, $type)
 {
     $crawler = new Crawler($item);
     //Initialize our object based on the record type we were passed.
     switch ($type) {
         case 'anime':
             $media = new Anime();
             break;
         case 'manga':
             $media = new Manga();
             break;
     }
     //Separate all the details
     $details = explode("\n", trim($crawler->filter('div[class="detail"]')->text()));
     $subDetails = explode(' ', trim($details[1]));
     //Pull out all the common parts
     $media->setId((int) str_replace('#area', '', $crawler->filter('a')->attr('id')));
     $media->setTitle($crawler->filter('a')->eq(1)->text());
     //Convert thumbnail to full size image by stripping the "t" in the filename
     $media->setImageUrl(preg_replace('/r(.+?)\\/(.+?)\\?(.+?)$/', '$2', $crawler->filter('img')->attr('data-src')));
     $media->setMembersCount((int) trim(str_replace(',', '', str_replace('members', '', $details[3]))));
     //Anime and manga have different details, so we grab an array of the list and then process based on the type
     switch ($type) {
         case 'anime':
             $media->setType($subDetails[0]);
             $media->setEpisodes(strstr($subDetails[1], '?') ? null : (int) trim(str_replace('eps', '', $subDetails[1]), '()'));
             $media->setMembersScore((double) $crawler->filter('td')->eq(2)->text());
             break;
         case 'manga':
             $media->setVolumes(strstr($subDetails[1], '?') ? null : (int) trim(str_replace('vols', '', $subDetails[1]), '()'));
             $media->setMembersScore((double) $crawler->filter('td')->eq(2)->text());
             break;
     }
     return $media;
 }
示例#5
0
 private static function parserecord($item, $type)
 {
     $crawler = new Crawler($item);
     //Get the type record.
     switch ($type) {
         case 'anime':
             $media = new Anime();
             break;
         case 'manga':
             $media = new Manga();
             break;
     }
     //Pull out all the common parts
     $media->setId((int) str_replace('sarea', '', $crawler->filter('a[class="hoverinfo_trigger"]')->attr('id')));
     $media->setTitle($crawler->filter('strong')->text());
     //Title Image
     //We need to do some string manipulation here so it doesn't return a tiny image
     $media->setImageUrl(preg_replace('/r(.+?)\\/(.+?)\\?(.+?)$/', '$2', $crawler->filter('img')->attr('data-src')));
     $media->setType(trim($crawler->filterXPath('//td[3]')->text()));
     switch ($type) {
         case 'anime':
             //Custom parsing for anime
             $media->setEpisodes((int) trim($crawler->filterXPath('//td[4]')->text()));
             $start_date = trim($crawler->filterXPath('//td[6]')->text());
             if ($start_date != '-') {
                 $start_date = explode('-', trim($start_date));
                 if (strlen($start_date[2]) == 2 && strpos($start_date[2], '?') === false) {
                     $start_date[2] = self::fixMalShortYear($start_date[2]);
                 }
                 //We must have a year. If we don't even have that, don't set a date.
                 if (strpos($start_date[2], '?') === false) {
                     // If we don't know the month, then we can only be accurate to a year.
                     if (strpos($start_date[0], '?') !== false) {
                         $media->setLiteralStartDate(null, DateTime::createFromFormat('Y', $start_date[2]), 'year');
                     } elseif (strpos($start_date[0], '?') === false && strpos($start_date[1], '?') !== false) {
                         $media->setLiteralStartDate(null, DateTime::createFromFormat('Y m', "{$start_date['2']} {$start_date['0']}"), 'month');
                     } elseif (strpos($start_date[0], '?') === false && strpos($start_date[1], '?') === false && strpos($start_date[2], '?') === false) {
                         $media->setLiteralStartDate("{$start_date['2']}-{$start_date['0']}-{$start_date['1']}", DateTime::createFromFormat('Y m d', "{$start_date['2']} {$start_date['0']} {$start_date['1']}"), 'day');
                     }
                 }
             }
             $end_date = trim($crawler->filterXPath('//td[7]')->text());
             if ($end_date != '-') {
                 $end_date = explode('-', trim($end_date));
                 if (strlen($end_date[2]) == 2 && strpos($end_date[2], '?') === false) {
                     $end_date[2] = self::fixMalShortYear($end_date[2]);
                 }
                 //We must have a year. If we don't even have that, don't set a date.
                 if (strpos($end_date[2], '?') === false) {
                     if (strpos($end_date[0], '?') !== false) {
                         $media->setLiteralEndDate(null, DateTime::createFromFormat('Y', $end_date[2]), 'year');
                     } elseif (strpos($end_date[0], '?') === false && strpos($end_date[1], '?') !== false) {
                         $media->setLiteralEndDate(null, DateTime::createFromFormat('Y m', "{$end_date['2']} {$end_date['0']}"), 'month');
                     } elseif (strpos($end_date[0], '?') === false && strpos($end_date[1], '?') === false && strpos($end_date[2], '?') === false) {
                         $media->setLiteralEndDate("{$end_date['2']}-{$end_date['0']}-{$end_date['1']}", DateTime::createFromFormat('Y m d', "{$end_date['2']} {$end_date['0']} {$end_date['1']}"), 'day');
                     }
                 }
             }
             $classification = trim($crawler->filterXPath('//td[9]')->text());
             if ($classification != '-') {
                 $media->setClassification($classification);
             }
             $media->setMembersScore((double) trim($crawler->filterXPath('//td[5]')->text()));
             $synopsis = $crawler->filterXPath('//td[2]/div[2]')->text();
             if ($synopsis !== '') {
                 $media->setSynopsis(str_replace('read more.', '', trim($synopsis)));
             }
             break;
         case 'manga':
             //Custom parsing for manga
             $media->setType(trim($crawler->filterXPath('//td[3]')->text()));
             $media->setChapters((int) trim($crawler->filterXPath('//td[5]')->text()));
             $media->setVolumes((int) trim($crawler->filterXPath('//td[4]')->text()));
             $media->setMembersScore((double) trim($crawler->filterXPath('//td[6]')->text()));
             $media->setSynopsis(str_replace('read more.', '', trim($crawler->filterXPath('//td[2]/div[2]')->text())));
             break;
     }
     return $media;
 }
示例#6
0
 public function testMalXml()
 {
     $manga = new Manga();
     $items = array();
     $output = "<?xml version=\"1.0\"?>\n<entry><chapter>7</chapter><volume>7</volume><status>1</status><score>9</score><downloaded_chapters>8</downloaded_chapters><times_reread>1</times_reread><reread_value>4</reread_value><date_start>01012015</date_start><date_finish>01022015</date_finish><priority>0</priority><comments>This is a comment.</comments><tags>one,two,three</tags></entry>\n";
     $manga->setId(1);
     $manga->setChaptersRead(7);
     $items[] = 'chapters';
     $manga->setVolumesRead(7);
     $items[] = 'volumes';
     $manga->setReadStatus(1);
     $items[] = 'status';
     $manga->setScore(9);
     $items[] = 'score';
     $manga->setChapDownloaded(8);
     $items[] = 'downloaded';
     $manga->setRereadCount(1);
     $items[] = 'rereadCount';
     $manga->setRereadValue(4);
     $items[] = 'rereadValue';
     $manga->setReadingStart(new \DateTime('20150101'));
     $items[] = 'start';
     $manga->setReadingEnd(new \DateTime('20150102'));
     $items[] = 'end';
     $manga->setPriority(6);
     $items[] = 'priority';
     $manga->setPersonalComments('This is a comment.');
     $items[] = 'comments';
     $manga->setPersonalTags('one,two,three');
     $items[] = 'tags';
     $this->assertEquals($output, $manga->MALApiXml($items));
 }
 public static function parseExtendedPersonal($contents, Manga $manga)
 {
     $crawler = new Crawler();
     $crawler->addHTMLContent($contents, 'UTF-8');
     #Personal tags
     #<td align="left" class="borderClass"><textarea name="tags" rows="2" id="tagtext" cols="45" class="textarea"></textarea><div class="spaceit_pad"><small>Popular tags: <a href="javascript:void(0);" onclick="detailedadd_addTag('cooking');">cooking</a>, <a href="javascript:void(0);" onclick="detailedadd_addTag('seinen');">seinen</a>, <a href="javascript:void(0);" onclick="detailedadd_addTag('drama');">drama</a>, <a href="javascript:void(0);" onclick="detailedadd_addTag('slice of life');">slice of life</a></small></div></td>
     $personalTags = $crawler->filter('textarea[id="add_manga_tags"]')->text();
     if (strlen($personalTags) > 0) {
         $personalTags = explode(',', $personalTags);
         foreach ($personalTags as $tag) {
             $tagArray[] = trim($tag);
         }
         $manga->setPersonalTags($tagArray);
     }
     #Start and Finish Dates
     #<tr>
     #    <td align="left" class="borderClass">Start Date</td>
     #                <td align="left" class="borderClass">
     #    Month:
     #    <select name="startMonth" id="smonth"  class="inputtext">
     #        <option value="00">
     #        <option value="01" >Jan<option value="02" >Feb<option value="03" >Mar<option value="04" >Apr<option value="05" >May<option value="06" >Jun<option value="07" >Jul<option value="08" >Aug<option value="09" selected>Sep<option value="10" >Oct<option value="11" >Nov<option value="12" >Dec			</select>
     #    Day:
     #    <select name="startDay"  class="inputtext">
     #        <option value="00">
     #        <option value="01" >1<option value="02" >2<option value="03" >3<option value="04" >4<option value="05" >5<option value="06" >6<option value="07" >7<option value="08" >8<option value="09" >9<option value="10" >10<option value="11" >11<option value="12" >12<option value="13" >13<option value="14" >14<option value="15" >15<option value="16" >16<option value="17" >17<option value="18" >18<option value="19" >19<option value="20" >20<option value="21" >21<option value="22" >22<option value="23" >23<option value="24" >24<option value="25" selected>25<option value="26" >26<option value="27" >27<option value="28" >28<option value="29" >29<option value="30" >30<option value="31" >31			</select>
     #    Year:
     #    <select name="startYear"  class="inputtext">
     #        <option value="0000">
     #        <option value="2014" >2014<option value="2013" selected>2013<option value="2012" >2012<option value="2011" >2011<option value="2010" >2010<option value="2009" >2009<option value="2008" >2008<option value="2007" >2007<option value="2006" >2006<option value="2005" >2005<option value="2004" >2004<option value="2003" >2003<option value="2002" >2002<option value="2001" >2001<option value="2000" >2000<option value="1999" >1999<option value="1998" >1998<option value="1997" >1997<option value="1996" >1996<option value="1995" >1995<option value="1994" >1994<option value="1993" >1993<option value="1992" >1992<option value="1991" >1991<option value="1990" >1990<option value="1989" >1989<option value="1988" >1988<option value="1987" >1987<option value="1986" >1986<option value="1985" >1985<option value="1984" >1984			</select>
     #    &nbsp;
     #    <label><input type="checkbox"  onchange="ChangeStartDate();" name="unknownStart" value="1"> <small>Unknown Date</label><br>Start Date represents the date you started watching the Anime <a href="javascript:setToday(1);">Insert Today</a></small>
     #    </td>
     #</tr>
     #<tr>
     #    <td align="left" class="borderClass">Finish Date</td>
     #                <td align="left" class="borderClass">
     #    Month:
     #    <select name="endMonth" id="emonth" class="inputtext" >
     #        <option value="00">
     #        <option value="01" >Jan<option value="02" >Feb<option value="03" >Mar<option value="04" >Apr<option value="05" >May<option value="06" >Jun<option value="07" >Jul<option value="08" >Aug<option value="09" >Sep<option value="10" selected>Oct<option value="11" >Nov<option value="12" >Dec			</select>
     #    Day:
     #    <select name="endDay" class="inputtext" >
     #        <option value="00">
     #        <option value="01" >1<option value="02" >2<option value="03" >3<option value="04" >4<option value="05" >5<option value="06" >6<option value="07" >7<option value="08" >8<option value="09" >9<option value="10" >10<option value="11" selected>11<option value="12" >12<option value="13" >13<option value="14" >14<option value="15" >15<option value="16" >16<option value="17" >17<option value="18" >18<option value="19" >19<option value="20" >20<option value="21" >21<option value="22" >22<option value="23" >23<option value="24" >24<option value="25" >25<option value="26" >26<option value="27" >27<option value="28" >28<option value="29" >29<option value="30" >30<option value="31" >31			</select>
     #    Year:
     #    <select name="endYear" class="inputtext" >
     #        <option value="0000">
     #        <option value="2014" >2014<option value="2013" selected>2013<option value="2012" >2012<option value="2011" >2011<option value="2010" >2010<option value="2009" >2009<option value="2008" >2008<option value="2007" >2007<option value="2006" >2006<option value="2005" >2005<option value="2004" >2004<option value="2003" >2003<option value="2002" >2002<option value="2001" >2001<option value="2000" >2000<option value="1999" >1999<option value="1998" >1998<option value="1997" >1997<option value="1996" >1996<option value="1995" >1995<option value="1994" >1994<option value="1993" >1993<option value="1992" >1992<option value="1991" >1991<option value="1990" >1990<option value="1989" >1989<option value="1988" >1988<option value="1987" >1987<option value="1986" >1986<option value="1985" >1985<option value="1984" >1984			</select>
     #    &nbsp;
     #    <small><label><input type="checkbox" onchange="ChangeEndDate();"  name="unknownEnd" value="1"> Unknown Date</label><br>Do <u>not</u> fill out the Finish Date unless status is <em>Completed</em> <a href="javascript:setToday(2);">Insert Today</a></small>
     #    </td>
     #</tr>
     $isStarted = $crawler->filter('input[id="unknown_start"]')->attr('checked');
     $isEnded = $crawler->filter('input[id="unknown_end"]')->attr('checked');
     if ($isStarted != 'checked') {
         //So, MAL allows users to put in just years, just years and months, or all three values.
         //This mess here is to try and avoid things breaking.
         if ($crawler->filter('select[id="add_manga_start_date_year"] option:selected')->count() > 0) {
             $startYear = $crawler->filter('select[id="add_manga_start_date_year"] option:selected')->attr('value');
             $startMonth = 6;
             $startDay = 15;
             if ($startYear !== '') {
                 if ($crawler->filter('select[id="add_manga_start_date_month"] option:selected')->count() > 0) {
                     $startMonth = $crawler->filter('select[id="add_manga_start_date_month"] option:selected')->attr('value');
                     if ($crawler->filter('select[id="add_manga_start_date_day"] option:selected')->count() > 0) {
                         $startDay = $crawler->filter('select[id="add_manga_start_date_day"] option:selected')->attr('value');
                     }
                 }
                 $manga->setReadingStart(DateTime::createFromFormat('Y-n-j', "{$startYear}-{$startMonth}-{$startDay}"));
             }
         }
     }
     if ($isEnded != 'checked') {
         //Same here, avoid breaking MAL's allowing of partial dates.
         if ($crawler->filter('select[id="add_manga_finish_date_year"] option:selected')->count() > 0) {
             $endYear = $crawler->filter('select[id="add_manga_finish_date_year"] option:selected')->attr('value');
             $endMonth = 6;
             $endDay = 15;
             if ($endYear !== '') {
                 if ($crawler->filter('select[id="add_manga_finish_date_month"] option:selected')->count() > 0) {
                     $endMonth = $crawler->filter('select[id="add_manga_finish_date_month"] option:selected')->attr('value');
                     if ($crawler->filter('select[id="add_manga_finish_date_day"] option:selected')->count() > 0) {
                         $endDay = $crawler->filter('select[id="add_manga_finish_date_day"] option:selected')->attr('value');
                     }
                 }
                 $manga->setReadingEnd(DateTime::createFromFormat('Y-n-j', "{$endYear}-{$endMonth}-{$endDay}"));
             }
         }
     }
     #Priority
     #<td align="left" class="borderClass">Priority</td>
     #<td align="left" class="borderClass"><select name="priority" class="inputtext">
     #<option value="0">Select</option>
     #<option value="0" selected>Low<option value="1" >Medium<option value="2" >High                </select>
     #<div style="margin-top 3px;"><small>What is your priority level to read this manga?</small></div></td>
     $priorityList = $crawler->filter('select[id="add_manga_priority"] option:selected');
     if (count($priorityList)) {
         $priority = $priorityList->attr('value');
         $manga->setPriority($priority);
     }
     #Rewatched
     #<label><input type="checkbox" id="add_manga_is_rereading" name="add_manga[is_rereading]" value="1" checked="checked">
     $reread = $crawler->filter('input[id="add_manga_is_rereading"]')->attr('checked');
     if ($reread == null) {
         $manga->setRereading(false);
     } else {
         $manga->setRereading(true);
     }
     #Times Reread
     #<td align="left" class="borderClass"><input type="text" class="inputtext" size="4" value="0" name="times_read">
     $rereadCount = $crawler->filter('input[id="add_manga_num_read_times"]')->attr('value');
     if ($rereadCount > 0) {
         $manga->setRereadCount($rereadCount);
     }
     #Reread Value
     #<td align="left" class="borderClass"><select class="inputtext" name="reread_value">
     #	<option value="0">Select reread value</option><option value="1">Very Low</option><option value="2">Low</option><option value="3">Medium</option><option value="4">High</option><option value="5">Very High			</option></select>
     $rereadValue = $crawler->filter('select[id="add_manga_reread_value"] option:selected');
     if (count($rereadValue)) {
         $manga->setRereadValue($rereadValue->attr('value'));
     }
     #Comments
     #<td align="left" class="borderClass"><textarea class="textarea" cols="45" rows="5" name="comments"></textarea></td>
     $comments = trim($crawler->filter('textarea[id="add_manga_comments"]')->text());
     if (strlen($comments)) {
         $manga->setPersonalComments($comments);
     }
     return $manga;
 }