public function processPage(Crawler $crawler)
 {
     $crawler->filter(".forumline.tablesorter tr")->each(function (Crawler $node) {
         $filter = $node->filter("td");
         if (count($filter) && count($filter->eq(3))) {
             $name = trim($filter->eq(3)->text());
             $torrentLink = trim($filter->eq(3)->filter('a')->attr('href'));
             $torrentLink = str_replace("./", 'http://rustorka.com/forum/', $torrentLink);
             $id = substr($torrentLink, strpos($torrentLink, "=") + 1);
             $seeders = trim($filter->eq(7)->text());
             $leechers = trim($filter->eq(8)->text());
             $downloadTimes = trim($filter->eq(9)->text());
             $torrent = Torrent::where('name', '=', $name)->first();
             if (!$torrent) {
                 $torrent = new Torrent();
             }
             $torrent->name = $name;
             $torrent->torrentLink = $torrentLink;
             $torrent->id = (int) $id;
             $torrent->seeders = (int) $seeders;
             $torrent->leechers = (int) $leechers;
             $torrent->downloadTimes = (int) $downloadTimes;
             $torrent->isSent = false;
             $torrent->save();
         }
     });
 }
 /**
  * Compose the navigation bar.
  *   
  */
 private function composeNavigation()
 {
     //pour du code plus long, utiliser un forder http\composers\...
     //view()->composer('partials.navbar', 'App\Http\Composers\NavigationComposer@compose');
     view()->composer('partials.navbar', function ($view) {
         $view->with('latest', Torrent::latest()->first());
     });
 }
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $torrentsModels = Torrent::where('seeders', '>', 29)->where('isSent', '=', false);
     $torrents = $torrentsModels->get();
     if (count($torrents)) {
         Mail::send('emails.freshTorrents', ['torrents' => $torrents], function (Message $m) {
             $m->from(env("MAIL_FROM_ADDRESS"), 'AxelPAL');
             $m->to(env("EMAIL_TO_SEND"), "AxelPAL")->subject('Новые торренты за ' . date("Y-m-d"));
         });
         $torrentsModels->update(['isSent' => true]);
     }
 }
Example #4
0
 /**
  * @param Request $request
  * @param Response $response
  * @param $args
  * @return Response
  */
 public function dispatch(Request $request, Response $response, $args)
 {
     $data = [];
     if ($request->isPost()) {
         $magnetUri = $request->getParam('magnetUri');
         if ($magnetUri) {
             $torrent = Torrent::fromMagnet($magnetUri);
             $data['torrent'] = $torrent;
             $data['torrentLink'] = (new Torcache())->getDownloadUrl($torrent);
         }
     }
     $this->view->render($response, 'home.twig', $data);
     return $response;
 }
 public function index(Request $request)
 {
     $label = null;
     $label_id = $request->input('label', null);
     if ($label_id != null) {
         $label = Label::find((int) $label_id);
     }
     if ($label == null) {
         $label = Label::unlabeled();
     }
     $_labels = Label::orderBy('id', 'asc')->get();
     $labels = array();
     foreach ($_labels as $l) {
         $labels[$l->id] = $l;
     }
     return view('index', ['torrents' => Torrent::orderBy('time_added', 'desc')->where('label_id', $label->id)->get(), 'labels' => $labels, 'label' => $label]);
 }
 /**
  * Update a torrent.
  *
  * @param Torrent        $torrent
  * @param TorrentRequest $request
  *
  * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
  */
 public function update(Torrent $torrent, TorrentRequest $request)
 {
     $torrent->update($request->all());
     $this->syncTags($torrent, $request->input('tag_list'));
     return redirect('torrents');
 }
Example #7
0
 /**
  * @param Torrent $torrent
  * @return string
  */
 public function getDownloadUrl(Torrent $torrent)
 {
     return 'http://torcache.net/torrent/' . $torrent->getHash() . '.torrent';
 }