Пример #1
0
 public function getNextDownloadChapter()
 {
     $chapters = Chapter::where('novel_id', '=', $this->id)->where('state', '=', 'detected')->where('index', '>', $this->latestChapter)->orderBy('index')->take(1)->get();
     if ($chapters->count() == 0) {
         return null;
     } else {
         return $chapters[0];
     }
 }
Пример #2
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $story = Story::create(['name' => 'Default']);
     $chapters = [1 => ":target Hello. I am Xan - :sniper's annoying bot that will bug you until you respond to this tweet. :emoji_bell", 2 => ":target Yo! Haven't responded to :sniper's tweet yet? Consider this as a gentle reminder. :emoji_angel", 3 => ":target Come on, what could be taking you sooooo long? :sniper is waiting. Hit reply and let me take rest. :emoji_army", 4 => ":target Testing my patience? Or :sniper's? I'll give you a tip: DON'T :emoji_cross. Reply now. Now. NOW.", 5 => ":target I'll try to be polite. Ever considered how important your one tweet can be to :sniper? :emoji_heart_eye", 6 => ":target What if I keep tweeting to you until you beg for mercy? Want that? Then reply to :sniper. Come on!", 7 => ":target Fact #1: No one has made me request so much ever before. Fact #2: :sniper is NOT liking it. :emoji_angry", 8 => ":target You are a tough nut :emoji_dragon. I am tougher. Expect endless stream of tweets from :sniper in next few hours.", 9 => ":target OH GOD! Even my warnings are fruitless on you. Do you even have a heart? :emoji_heart :sniper's eyes are teary.", 10 => ":target I think I'll let :sniper know how stone-hearted you are. I am a robot :emoji_robot and still have more heart.", 11 => ":target Before I pass on bad news to :sniper, I'd like to give you one last chance. LAST. Mind replying? :emoji_angel", 12 => ":target The time has come, I guess. If you don't reply to this last reminder, I'll go and break :sniper's heart. :emoji_broken_heart"];
     $chaptersWithoutEmojis = [1 => ":target Hello. I am Xan - :sniper's annoying bot that will bug you until you respond to this tweet.", 2 => ":target Yo! Haven't responded to :sniper's tweet yet? Consider this as a gentle reminder.", 3 => ":target Come on, what could be taking you sooooo long? :sniper is waiting. Hit reply and let me take rest.", 4 => ":target Testing my patience? Or :sniper's? I'll give you a tip: DON'T. Reply now. Now. NOW.", 5 => ":target I'll try to be polite. Ever considered how important your one tweet can be to :sniper?", 6 => ":target What if I keep tweeting to you until you beg for mercy? Want that? Then reply to :sniper. Come on!", 7 => ":target Fact #1: No one has made me request so much ever before. Fact #2: :sniper is NOT liking it.", 8 => ":target You are a tough nut. I am tougher. Expect endless stream of tweets from :sniper in next few hours.", 9 => ":target OH GOD! Even my warnings are fruitless on you. Do you even have a heart? :sniper's eyes are teary.", 10 => ":target I think I'll let :sniper know how stone-hearted you are. I am a robot and still have more heart.", 11 => ":target Before I pass on bad news to :sniper, I'd like to give you one last chance. LAST. Mind replying?", 12 => ":target The time has come, I guess. If you don't reply to this last reminder, I'll go and break :sniper's heart."];
     foreach ($chaptersWithoutEmojis as $sequence => $body) {
         Chapter::create(['story_id' => $story->id, 'sequence' => $sequence, 'body' => $body]);
     }
 }
Пример #3
0
 public function downloadAll()
 {
     foreach (Chapter::all() as $chapter) {
         if ($chapter->state != 'detected') {
             continue;
         }
         $dom = Utils::getDom($chapter->url);
         $content = $dom->find('.content', 0)->text();
         $content = str_replace(str_repeat(' ', 4), "\n\t", $content);
         $chapter->content = $content;
         $chapter->state = 'downloaded';
         $chapter->save();
     }
 }
Пример #4
0
 protected function pushNovel($novel)
 {
     $nextChapter = Chapter::getNextChapter($novel);
     if ($nextChapter == null) {
         return;
     }
     $name = $novel->name . ' - ' . $nextChapter->name . '.txt';
     $mail = new \App\Mail();
     $mail->state = 'ready';
     $mail->name = $name;
     $mail->content = $nextChapter->content;
     $mail->novel_id = $novel->id;
     $mail->chapter_id = $nextChapter->id;
     $mail->save();
     $nextChapter->state = 'pushed';
     $nextChapter->save();
     $novel->latestChapter++;
     $novel->save();
 }
Пример #5
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $pagePathTemplate = Config::get('manga.chapter_page_path');
     $endDateTime = date('Y-m-d H:i:s', time() - 60 * 10);
     $nonPageCountChapterCount = Chapter::select(['mng_id', 'dir_pth'])->where('dte_upd', '<=', $endDateTime)->where('sts', '=', 1)->whereNull('pageCount')->count();
     $offset = 0;
     $limit = 1000;
     $this->output->progressStart($nonPageCountChapterCount);
     while ($offset < $nonPageCountChapterCount) {
         $nonPageCountChapters = Chapter::select(['id', 'mng_id', 'dir_pth'])->where('dte_upd', '<=', $endDateTime)->where('sts', '=', 1)->whereNull('pageCount')->orderBy('id', 'asc')->skip($offset)->take($limit)->get();
         foreach ($nonPageCountChapters as $chapter) {
             $pagePath = strtr($pagePathTemplate, array('{manga-id}' => $chapter->mng_id, '{chapter-idx}' => $chapter->dir_pth));
             echo $chapter, "\n";
             if ($chapter->dir_pth !== '' && file_exists($pagePath)) {
                 $chapter->pageCount = count(glob("{$pagePath}/p_*.jpg"));
                 $chapter->save();
             }
             $this->output->progressAdvance();
         }
         $offset += $limit;
     }
     $this->output->progressFinish();
 }
Пример #6
0
 public function deleteAllWithBookID($id)
 {
     // Checking if chapter exists
     $chapters = Chapter::where('book_id', $id)->get();
     // If chapters exists
     if (sizeof($chapters) > 0) {
         // Delete related chapters
         foreach ($chapters as $chapter) {
             // Finding related pages
             $pages = $this->pagesService->deleteAllWithChapter($chapter->id);
         }
         Chapter::where('book_id', $id)->delete();
         // Returning success message
         return $this->responseService->returnSuccess();
     } else {
         // Chapter not found
         // Returning error message
         return $this->responseService->errorMessage('Chapter was not Found.');
     }
 }
Пример #7
0
 public function chapter()
 {
     $chapters = Chapter::orderBy('index', 'desc')->with('novel')->paginate(10);
     return view('chapter', ['chapters' => $chapters, 'pageName' => 'chapter']);
 }