Exemple #1
0
    void MainWindow::advancedSearch()
    {
        SearchDialog searchDialog( window() );
        searchDialog.setWindowIcon( windowIcon() );
        searchDialog.setWindowModality( Qt::ApplicationModal );

        if( searchDialog.exec() == QDialog::Accepted ){
            QString query = YOUTUBE_URL + "&q=" + searchDialog.getQuery() + "&key=" + API_KEY;
            try {
                m_networkManager->getRequest( QUrl{ query } );
                displayVideoInfo( m_networkManager->result );
            } catch( BaseError & err ){
                handleAllErrors( err.what() );
                return;
            }
        }
    }
Exemple #2
0
 void MainWindow::basicSearch()
 {
     bool ok = false;
     QString query = QInputDialog::getText( this->window(), tr("Basic Search"),
                                            tr( "Enter video title" ),
                                            QLineEdit::Normal, QString{}, &ok );
     query = tr( QUrl::toPercentEncoding( query ) );
     if( ok && query.size() != 0 ){
         QString new_query = YOUTUBE_URL + "&q=" + query +
                 tr( "&maxResults=%1&key=%2" )
                 .arg( MAX_RESULT )
                 .arg( API_KEY );
         try {
             m_networkManager->getRequest( QUrl( new_query ) );
             displayVideoInfo( m_networkManager->result );
         } catch ( BaseError & err ) {
             handleAllErrors( err.what() );
             return;
         }
     }
 }
Exemple #3
0
bool VideoPreview::extractImages() {
	VideoInfo i = getInfo(mplayer_bin, prop.input_video);
	int length = i.length;

	if (length == 0) {
		if (error_message.isEmpty()) error_message = tr("The length of the video is 0");
		return false;
	}

	// Create a temporary directory
	QDir d(QDir::tempPath());
	if (!d.exists(output_dir)) {
		if (!d.mkpath(output_dir)) {
			qDebug("VideoPreview::extractImages: error: can't create '%s'", full_output_dir.toUtf8().constData());
			error_message = tr("The temporary directory (%1) can't be created").arg(full_output_dir);
			return false;
		}
	}

	displayVideoInfo(i);

	// Let's begin
	run.thumbnail_width = 0;

	int num_pictures = prop.n_cols * prop.n_rows;
	length -= prop.initial_step;
	int s_step = length / num_pictures;

	int current_time = prop.initial_step;

	canceled = false;
	progress->setLabelText(tr("Creating thumbnails..."));
	progress->setRange(0, num_pictures-1);
	progress->show();

	double aspect_ratio = i.aspect;
	if (prop.aspect_ratio != 0) aspect_ratio = prop.aspect_ratio;

	for (int n = 0; n < num_pictures; n++) {
		qDebug("VideoPreview::extractImages: getting frame %d of %d...", n+1, num_pictures);
		progress->setValue(n);
		qApp->processEvents();

		if (canceled) return false;

		if (!runPlayer(current_time, aspect_ratio)) return false;

		QString frame_picture = full_output_dir + "/" + framePicture();
		if (!QFile::exists(frame_picture)) {
			error_message = tr("The file %1 doesn't exist").arg(frame_picture);
			return false;
		}

#if RENAME_PICTURES 
		QString extension = (extractFormat()==PNG) ? "png" : "jpg";
		QString output_file = output_dir + QString("/picture_%1.%2").arg(current_time, 8, 10, QLatin1Char('0')).arg(extension);
		d.rename(output_dir + "/" + framePicture(), output_file);
#else
		QString output_file = output_dir + "/" + framePicture();
#endif

		if (!addPicture(QDir::tempPath() +"/"+ output_file, n, current_time)) {
			return false;
		}

		current_time += s_step;
	}

	return true;
}