Esempio n. 1
0
    /**
     * Generates the NFO for the movie located in $this->folder ids $this->AllocineId and $this->TBDbId
     *
     * @param $this->folder The movie folder in the movies storage directory
     * @param $this->AllocineId
     * @param $this->TBDbId
     *
     * @return ezcMvcResult
     */
    public function doNfoGenerate()
    {
        $result = new \ezcMvcResult();
        $result->variables['page_title'] = "Generate NFO :: MKV Manager";
        $result->variables['saveUrl'] = "/nfo/movie/save/" . urlencode( $this->folder );
        $result->variables['updateUrl'] = '/nfo/movie/update-info';

        $allocineId = $this->AllocineId;
        $TMDbId = $this->TMDbId;

        $allocineScraper = new \MkvManagerScraperAllocine();
        // $allocineScraper->isCacheEnabled = false;
        $infos = $allocineScraper->getMovieDetails( $allocineId );

        $TMDbScraper = new \MkvManagerScraperTMDB();
        // $TMDbScraper->isCacheEnabled = false;
        $TMDbImages = $TMDbScraper->getImages( $TMDbId );

        foreach( $TMDbImages as $image )
        {
            if ( $image->type == 'poster' )
            {
                $variable = 'posters';
            }
            elseif ( $image->type == 'fanart' )
            {
                $variable = 'fanarts';
            }
            else
            {
                continue;
            }
            array_push( $infos->$variable, $image );
        }
        $result->variables['infos'] = $infos;

        // nfo
        $writer = new \mm\Xbmc\Nfo\Writers\Movie( $infos );
        $result->variables['nfo'] = $writer->get();

        return $result;
    }
Esempio n. 2
0
    /**
     * Saves a NFO
     *
     * @param string $this->folder
     * @param string $this->info
     *
     * @return ezcMvcResult
     */
    public function doNfoSave()
    {
        $result = new \ezcMvcResult();

        $result->variables['page_title'] = "{$this->folder} :: Save NFO :: MKV Manager";
        $result->variables['movie'] = $this->folder;

        $basepath =
            ezcConfigurationManager::getInstance()->getSetting( 'movies', 'GeneralSettings', 'SourcePath' ) .
            DIRECTORY_SEPARATOR .
            $this->folder . DIRECTORY_SEPARATOR;
        $nfoFilePath = "{$basepath}{$this->folder}.nfo";
        $posterFilepath = "{$basepath}{$this->folder}.tbn";
        $fanartFilepath = "{$basepath}{$this->folder}-fanart.jpg";
        $trailerFilepath = "{$basepath}{$this->folder}-trailer.flv";

        $nfoWriter = new NfoWriter( $this->info );

        $result->variables['operations'] = array();

        // write NFO to disk
        $nfoWriter->write( $nfoFilePath );
        $operation = Daemon\Queue::add(
            new Operations\NfoWriter( $this->info, $nfoFilePath )
        );
        $result->variables['operations'][] = (object)array(
            'title' => $operation->title,
            'hash' => $operation->hash,
        );

        // trailer
        $operation = Daemon\Queue::add(
            new Operations\HttpDownload( $nfoWriter->getMainPoster(), $posterFilepath )
        );
        $result->variables['operations'][] = (object)array(
            'title' => $operation->title,
            'hash' => $operation->hash,
        );

        // trailer
        $operation = Daemon\Queue::add(
            new Operations\HttpDownload( $nfoWriter->getMainFanart(), $fanartFilepath )
        );
        $result->variables['operations'][] = (object)array(
            'title' => $operation->title,
            'hash' => $operation->hash,
        );

        // trailer
        $operation = Daemon\Queue::add(
            new Operations\HttpDownload( $nfoWriter->getTrailer(), $trailerFilepath )
        );
        $result->variables['operations'][] = (object)array(
            'title' => $operation->title,
            'hash' => $operation->hash,
        );

        return $result;
    }