+
+void MediaView::findVideoParts() {
+
+ // parts
+ Video* video = listModel->activeVideo();
+ if (!video) return;
+
+ QString query = video->title();
+
+ static QString optionalSpace = "\\s*";
+ static QString staticCounterSeparators = "[\\/\\-]";
+ QString counterSeparators = "( of | " +
+ tr("of", "Used in video parts, as in '2 of 3'") +
+ " |" + staticCounterSeparators + ")";
+
+ // numbers from 1 to 15
+ static QString counterNumber = "([1-9]|1[0-5])";
+
+ // query.remove(QRegExp(counterSeparators + optionalSpace + counterNumber));
+ query.remove(QRegExp(counterNumber + optionalSpace + counterSeparators + optionalSpace + counterNumber));
+ query.remove(wordRE("pr?t\\.?" + optionalSpace + counterNumber));
+ query.remove(wordRE("ep\\.?" + optionalSpace + counterNumber));
+ query.remove(wordRE("part" + optionalSpace + counterNumber));
+ query.remove(wordRE("episode" + optionalSpace + counterNumber));
+ query.remove(wordRE(tr("part", "This is for video parts, as in 'Cool video - part 1'") +
+ optionalSpace + counterNumber));
+ query.remove(wordRE(tr("episode", "This is for video parts, as in 'Cool series - episode 1'") +
+ optionalSpace + counterNumber));
+ query.remove(QRegExp("[\\(\\)\\[\\]]"));
+
+#define NUMBERS "one|two|three|four|five|six|seven|eight|nine|ten"
+
+ QRegExp englishNumberRE = QRegExp(QLatin1String(".*(") + NUMBERS + ").*", Qt::CaseInsensitive);
+ // bool numberAsWords = englishNumberRE.exactMatch(query);
+ query.remove(englishNumberRE);
+
+ QRegExp localizedNumberRE = QRegExp(QLatin1String(".*(") + tr(NUMBERS) + ").*", Qt::CaseInsensitive);
+ // if (!numberAsWords) numberAsWords = localizedNumberRE.exactMatch(query);
+ query.remove(localizedNumberRE);
+
+ SearchParams *searchParams = new SearchParams();
+ searchParams->setTransient(true);
+ searchParams->setKeywords(query);
+ searchParams->setAuthor(video->author());
+
+ /*
+ if (!numberAsWords) {
+ qDebug() << "We don't have number as words";
+ // searchParams->setSortBy(SearchParams::SortByNewest);
+ // TODO searchParams->setReverseOrder(true);
+ // TODO searchParams->setMax(50);
+ }
+ */
+
+ search(searchParams);
+
+}
+
+void MediaView::shareViaTwitter() {
+ Video* video = listModel->activeVideo();
+ if (!video) return;
+ QUrl url("https://twitter.com/intent/tweet");
+ url.addQueryItem("via", "minitubeapp");
+ url.addQueryItem("text", video->title());
+ url.addQueryItem("url", video->webpage().toString());
+ QDesktopServices::openUrl(url);
+}
+
+void MediaView::shareViaFacebook() {
+ Video* video = listModel->activeVideo();
+ if (!video) return;
+ QUrl url("https://www.facebook.com/sharer.php");
+ url.addQueryItem("t", video->title());
+ url.addQueryItem("u", video->webpage().toString());
+ QDesktopServices::openUrl(url);
+}
+
+void MediaView::shareViaEmail() {
+ Video* video = listModel->activeVideo();
+ if (!video) return;
+ QUrl url("mailto:");
+ url.addQueryItem("subject", video->title());
+ QString body = video->title() + "\n" +
+ video->webpage().toString() + "\n\n" +
+ tr("Sent from %1").arg(Constants::NAME) + "\n" +
+ Constants::WEBSITE;
+ url.addQueryItem("body", body);
+ QDesktopServices::openUrl(url);
+}
+
+void MediaView::authorPushed(QModelIndex index) {
+ Video* video = listModel->videoAt(index.row());
+ if (!video) return;
+
+ QString channel = video->author();
+ if (channel.isEmpty()) return;
+
+ SearchParams *searchParams = new SearchParams();
+ searchParams->setAuthor(channel);
+ searchParams->setSortBy(SearchParams::SortByNewest);
+
+ // go!
+ search(searchParams);
+}