window-youtube-actions.cpp 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630
  1. #include "window-basic-main.hpp"
  2. #include "window-youtube-actions.hpp"
  3. #include "obs-app.hpp"
  4. #include "qt-wrappers.hpp"
  5. #include "youtube-api-wrappers.hpp"
  6. #include <QToolTip>
  7. #include <QDateTime>
  8. #include <QDesktopServices>
  9. const QString SchedulDateAndTimeFormat = "yyyy-MM-dd'T'hh:mm:ss'Z'";
  10. const QString RepresentSchedulDateAndTimeFormat = "dddd, MMMM d, yyyy h:m";
  11. const QString IndexOfGamingCategory = "20";
  12. OBSYoutubeActions::OBSYoutubeActions(QWidget *parent, Auth *auth)
  13. : QDialog(parent),
  14. ui(new Ui::OBSYoutubeActions),
  15. apiYouTube(dynamic_cast<YoutubeApiWrappers *>(auth)),
  16. workerThread(new WorkerThread(apiYouTube))
  17. {
  18. setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
  19. ui->setupUi(this);
  20. ui->privacyBox->addItem(QTStr("YouTube.Actions.Privacy.Public"),
  21. "public");
  22. ui->privacyBox->addItem(QTStr("YouTube.Actions.Privacy.Unlisted"),
  23. "unlisted");
  24. ui->privacyBox->addItem(QTStr("YouTube.Actions.Privacy.Private"),
  25. "private");
  26. ui->latencyBox->addItem(QTStr("YouTube.Actions.Latency.Normal"),
  27. "normal");
  28. ui->latencyBox->addItem(QTStr("YouTube.Actions.Latency.Low"), "low");
  29. ui->latencyBox->addItem(QTStr("YouTube.Actions.Latency.UltraLow"),
  30. "ultraLow");
  31. UpdateOkButtonStatus();
  32. connect(ui->title, &QLineEdit::textChanged, this,
  33. [&](const QString &) { this->UpdateOkButtonStatus(); });
  34. connect(ui->privacyBox, &QComboBox::currentTextChanged, this,
  35. [&](const QString &) { this->UpdateOkButtonStatus(); });
  36. connect(ui->yesMakeForKids, &QRadioButton::toggled, this,
  37. [&](bool) { this->UpdateOkButtonStatus(); });
  38. connect(ui->notMakeForKids, &QRadioButton::toggled, this,
  39. [&](bool) { this->UpdateOkButtonStatus(); });
  40. connect(ui->tabWidget, &QTabWidget::currentChanged, this,
  41. [&](int) { this->UpdateOkButtonStatus(); });
  42. connect(ui->pushButton, &QPushButton::clicked, this,
  43. &OBSYoutubeActions::OpenYouTubeDashboard);
  44. connect(ui->helpAutoStartStop, &QLabel::linkActivated, this,
  45. [](const QString &) {
  46. QToolTip::showText(
  47. QCursor::pos(),
  48. QTStr("YouTube.Actions.AutoStartStop.TT"));
  49. });
  50. connect(ui->help360Video, &QLabel::linkActivated, this,
  51. [](const QString &link) { QDesktopServices::openUrl(link); });
  52. connect(ui->helpMadeForKids, &QLabel::linkActivated, this,
  53. [](const QString &link) { QDesktopServices::openUrl(link); });
  54. ui->scheduledTime->setVisible(false);
  55. connect(ui->checkScheduledLater, &QCheckBox::stateChanged, this,
  56. [&](int state) {
  57. ui->scheduledTime->setVisible(state);
  58. if (state) {
  59. ui->checkAutoStart->setVisible(true);
  60. ui->checkAutoStop->setVisible(true);
  61. ui->helpAutoStartStop->setVisible(true);
  62. ui->checkAutoStart->setChecked(false);
  63. ui->checkAutoStop->setChecked(false);
  64. } else {
  65. ui->checkAutoStart->setVisible(false);
  66. ui->checkAutoStop->setVisible(false);
  67. ui->helpAutoStartStop->setVisible(false);
  68. ui->checkAutoStart->setChecked(true);
  69. ui->checkAutoStop->setChecked(true);
  70. }
  71. UpdateOkButtonStatus();
  72. });
  73. ui->checkAutoStart->setVisible(false);
  74. ui->checkAutoStop->setVisible(false);
  75. ui->helpAutoStartStop->setVisible(false);
  76. ui->scheduledTime->setDateTime(QDateTime::currentDateTime());
  77. if (!apiYouTube) {
  78. blog(LOG_DEBUG, "YouTube API auth NOT found.");
  79. Cancel();
  80. return;
  81. }
  82. ChannelDescription channel;
  83. if (!apiYouTube->GetChannelDescription(channel)) {
  84. blog(LOG_DEBUG, "Could not get channel description.");
  85. ShowErrorDialog(
  86. parent,
  87. apiYouTube->GetLastError().isEmpty()
  88. ? QTStr("YouTube.Actions.Error.General")
  89. : QTStr("YouTube.Actions.Error.Text")
  90. .arg(apiYouTube->GetLastError()));
  91. Cancel();
  92. return;
  93. }
  94. this->setWindowTitle(channel.title);
  95. QVector<CategoryDescription> category_list;
  96. if (!apiYouTube->GetVideoCategoriesList(
  97. channel.country, channel.language, category_list)) {
  98. blog(LOG_DEBUG, "Could not get video category for country; %s.",
  99. channel.country.toStdString().c_str());
  100. ShowErrorDialog(
  101. parent,
  102. apiYouTube->GetLastError().isEmpty()
  103. ? QTStr("YouTube.Actions.Error.General")
  104. : QTStr("YouTube.Actions.Error.Text")
  105. .arg(apiYouTube->GetLastError()));
  106. Cancel();
  107. return;
  108. }
  109. for (auto &category : category_list) {
  110. ui->categoryBox->addItem(category.title, category.id);
  111. if (category.id == IndexOfGamingCategory) {
  112. ui->categoryBox->setCurrentText(category.title);
  113. }
  114. }
  115. connect(ui->okButton, &QPushButton::clicked, this,
  116. &OBSYoutubeActions::InitBroadcast);
  117. connect(ui->cancelButton, &QPushButton::clicked, this, [&]() {
  118. blog(LOG_DEBUG, "YouTube live broadcast creation cancelled.");
  119. // Close the dialog.
  120. Cancel();
  121. });
  122. qDeleteAll(ui->scrollAreaWidgetContents->findChildren<QWidget *>(
  123. QString(), Qt::FindDirectChildrenOnly));
  124. // Add label indicating loading state
  125. QLabel *loadingLabel = new QLabel();
  126. loadingLabel->setTextFormat(Qt::RichText);
  127. loadingLabel->setAlignment(Qt::AlignHCenter);
  128. loadingLabel->setText(
  129. QString("<big>%1</big>")
  130. .arg(QTStr("YouTube.Actions.EventsLoading")));
  131. ui->scrollAreaWidgetContents->layout()->addWidget(loadingLabel);
  132. // Delete "loading..." label on completion
  133. connect(workerThread, &WorkerThread::finished, this, [&] {
  134. QLayoutItem *item =
  135. ui->scrollAreaWidgetContents->layout()->takeAt(0);
  136. item->widget()->deleteLater();
  137. });
  138. connect(workerThread, &WorkerThread::failed, this, [&]() {
  139. auto last_error = apiYouTube->GetLastError();
  140. if (last_error.isEmpty())
  141. last_error = QTStr("YouTube.Actions.Error.YouTubeApi");
  142. if (!apiYouTube->GetTranslatedError(last_error))
  143. last_error = QTStr("YouTube.Actions.Error.Text")
  144. .arg(last_error);
  145. ShowErrorDialog(this, last_error);
  146. QDialog::reject();
  147. });
  148. connect(workerThread, &WorkerThread::new_item, this,
  149. [&](const QString &title, const QString &dateTimeString,
  150. const QString &broadcast, const QString &status,
  151. bool astart, bool astop) {
  152. ClickableLabel *label = new ClickableLabel();
  153. label->setTextFormat(Qt::RichText);
  154. if (status == "live" || status == "testing") {
  155. // Resumable stream
  156. label->setText(
  157. QString("<big>%1</big><br/>%2")
  158. .arg(title,
  159. QTStr("YouTube.Actions.Stream.Resume")));
  160. } else if (dateTimeString.isEmpty()) {
  161. // The broadcast created by YouTube Studio has no start time.
  162. // Yes this does violate the restrictions set in YouTube's API
  163. // But why would YouTube care about consistency?
  164. label->setText(
  165. QString("<big>%1</big><br/>%2")
  166. .arg(title,
  167. QTStr("YouTube.Actions.Stream.YTStudio")));
  168. } else {
  169. label->setText(
  170. QString("<big>%1</big><br/>%2")
  171. .arg(title,
  172. QTStr("YouTube.Actions.Stream.ScheduledFor")
  173. .arg(dateTimeString)));
  174. }
  175. label->setAlignment(Qt::AlignHCenter);
  176. label->setMargin(4);
  177. connect(label, &ClickableLabel::clicked, this,
  178. [&, label, broadcast, astart, astop]() {
  179. for (QWidget *i :
  180. ui->scrollAreaWidgetContents->findChildren<
  181. QWidget *>(
  182. QString(),
  183. Qt::FindDirectChildrenOnly)) {
  184. i->setProperty(
  185. "isSelectedEvent",
  186. "false");
  187. i->style()->unpolish(i);
  188. i->style()->polish(i);
  189. }
  190. label->setProperty("isSelectedEvent",
  191. "true");
  192. label->style()->unpolish(label);
  193. label->style()->polish(label);
  194. this->selectedBroadcast = broadcast;
  195. this->autostart = astart;
  196. this->autostop = astop;
  197. UpdateOkButtonStatus();
  198. });
  199. ui->scrollAreaWidgetContents->layout()->addWidget(
  200. label);
  201. });
  202. workerThread->start();
  203. #ifdef __APPLE__
  204. // MacOS theming issues
  205. this->resize(this->width() + 200, this->height() + 120);
  206. #endif
  207. valid = true;
  208. }
  209. OBSYoutubeActions::~OBSYoutubeActions()
  210. {
  211. workerThread->stop();
  212. workerThread->wait();
  213. delete workerThread;
  214. }
  215. void WorkerThread::run()
  216. {
  217. if (!pending)
  218. return;
  219. json11::Json broadcasts;
  220. for (QString broacastStatus : {"active", "upcoming"}) {
  221. if (!apiYouTube->GetBroadcastsList(broadcasts, "",
  222. broacastStatus)) {
  223. emit failed();
  224. return;
  225. }
  226. while (pending) {
  227. auto items = broadcasts["items"].array_items();
  228. for (auto item : items) {
  229. QString status = QString::fromStdString(
  230. item["status"]["lifeCycleStatus"]
  231. .string_value());
  232. if (status == "live" || status == "testing") {
  233. // Check that the attached liveStream is offline (reconnectable)
  234. QString stream_id = QString::fromStdString(
  235. item["contentDetails"]
  236. ["boundStreamId"]
  237. .string_value());
  238. json11::Json stream;
  239. if (!apiYouTube->FindStream(stream_id,
  240. stream))
  241. continue;
  242. if (stream["status"]["streamStatus"] ==
  243. "active")
  244. continue;
  245. }
  246. QString title = QString::fromStdString(
  247. item["snippet"]["title"].string_value());
  248. QString scheduledStartTime =
  249. QString::fromStdString(
  250. item["snippet"]
  251. ["scheduledStartTime"]
  252. .string_value());
  253. QString broadcast = QString::fromStdString(
  254. item["id"].string_value());
  255. // Treat already started streams as autostart for UI purposes
  256. bool astart =
  257. status == "live"
  258. ? true
  259. : item["contentDetails"]
  260. ["enableAutoStart"]
  261. .bool_value();
  262. bool astop =
  263. item["contentDetails"]["enableAutoStop"]
  264. .bool_value();
  265. QDateTime utcDTime = QDateTime::fromString(
  266. scheduledStartTime,
  267. SchedulDateAndTimeFormat);
  268. // DateTime parser means that input datetime is a local, so we need to move it
  269. QDateTime dateTime = utcDTime.addSecs(
  270. utcDTime.offsetFromUtc());
  271. QString dateTimeString = QLocale().toString(
  272. dateTime,
  273. QString("%1 %2").arg(
  274. QLocale().dateFormat(
  275. QLocale::LongFormat),
  276. QLocale().timeFormat(
  277. QLocale::ShortFormat)));
  278. emit new_item(title, dateTimeString, broadcast,
  279. status, astart, astop);
  280. }
  281. auto nextPageToken =
  282. broadcasts["nextPageToken"].string_value();
  283. if (nextPageToken.empty() || items.empty())
  284. break;
  285. else {
  286. if (!pending)
  287. return;
  288. if (!apiYouTube->GetBroadcastsList(
  289. broadcasts,
  290. QString::fromStdString(
  291. nextPageToken),
  292. broacastStatus)) {
  293. emit failed();
  294. return;
  295. }
  296. }
  297. }
  298. }
  299. emit ready();
  300. }
  301. void OBSYoutubeActions::UpdateOkButtonStatus()
  302. {
  303. if (ui->tabWidget->currentIndex() == 0) {
  304. ui->okButton->setEnabled(
  305. !ui->title->text().isEmpty() &&
  306. !ui->privacyBox->currentText().isEmpty() &&
  307. (ui->yesMakeForKids->isChecked() ||
  308. ui->notMakeForKids->isChecked()));
  309. if (ui->checkScheduledLater->checkState() == Qt::Checked) {
  310. ui->okButton->setText(
  311. QTStr("YouTube.Actions.Create_Save"));
  312. } else {
  313. ui->okButton->setText(
  314. QTStr("YouTube.Actions.Create_GoLive"));
  315. }
  316. ui->pushButton->setVisible(false);
  317. } else {
  318. ui->okButton->setEnabled(!selectedBroadcast.isEmpty());
  319. ui->okButton->setText(QTStr("YouTube.Actions.Choose_GoLive"));
  320. ui->pushButton->setVisible(true);
  321. }
  322. }
  323. bool OBSYoutubeActions::StreamNowAction(YoutubeApiWrappers *api,
  324. StreamDescription &stream)
  325. {
  326. YoutubeApiWrappers *apiYouTube = api;
  327. BroadcastDescription broadcast = {};
  328. UiToBroadcast(broadcast);
  329. // stream now is always autostart/autostop
  330. broadcast.auto_start = true;
  331. broadcast.auto_stop = true;
  332. blog(LOG_DEBUG, "Scheduled date and time: %s",
  333. broadcast.schedul_date_time.toStdString().c_str());
  334. if (!apiYouTube->InsertBroadcast(broadcast)) {
  335. blog(LOG_DEBUG, "No broadcast created.");
  336. return false;
  337. }
  338. stream = {"", "", "OBS Studio Video Stream", ""};
  339. if (!apiYouTube->InsertStream(stream)) {
  340. blog(LOG_DEBUG, "No stream created.");
  341. return false;
  342. }
  343. if (!apiYouTube->BindStream(broadcast.id, stream.id)) {
  344. blog(LOG_DEBUG, "No stream binded.");
  345. return false;
  346. }
  347. if (!apiYouTube->SetVideoCategory(broadcast.id, broadcast.title,
  348. broadcast.description,
  349. broadcast.category.id)) {
  350. blog(LOG_DEBUG, "No category set.");
  351. return false;
  352. }
  353. if (broadcast.privacy != "private")
  354. apiYouTube->SetChatId(broadcast.id);
  355. else
  356. apiYouTube->ResetChat();
  357. return true;
  358. }
  359. bool OBSYoutubeActions::StreamLaterAction(YoutubeApiWrappers *api)
  360. {
  361. YoutubeApiWrappers *apiYouTube = api;
  362. BroadcastDescription broadcast = {};
  363. UiToBroadcast(broadcast);
  364. // DateTime parser means that input datetime is a local, so we need to move it
  365. auto dateTime = ui->scheduledTime->dateTime();
  366. auto utcDTime = dateTime.addSecs(-dateTime.offsetFromUtc());
  367. broadcast.schedul_date_time =
  368. utcDTime.toString(SchedulDateAndTimeFormat);
  369. blog(LOG_DEBUG, "Scheduled date and time: %s",
  370. broadcast.schedul_date_time.toStdString().c_str());
  371. if (!apiYouTube->InsertBroadcast(broadcast)) {
  372. blog(LOG_DEBUG, "No broadcast created.");
  373. return false;
  374. }
  375. if (!apiYouTube->SetVideoCategory(broadcast.id, broadcast.title,
  376. broadcast.description,
  377. broadcast.category.id)) {
  378. blog(LOG_DEBUG, "No category set.");
  379. return false;
  380. }
  381. if (broadcast.privacy != "private")
  382. apiYouTube->SetChatId(broadcast.id);
  383. else
  384. apiYouTube->ResetChat();
  385. return true;
  386. }
  387. bool OBSYoutubeActions::ChooseAnEventAction(YoutubeApiWrappers *api,
  388. StreamDescription &stream)
  389. {
  390. YoutubeApiWrappers *apiYouTube = api;
  391. json11::Json json;
  392. if (!apiYouTube->FindBroadcast(selectedBroadcast, json)) {
  393. blog(LOG_DEBUG, "No broadcast found.");
  394. return false;
  395. }
  396. std::string boundStreamId =
  397. json["items"]
  398. .array_items()[0]["contentDetails"]["boundStreamId"]
  399. .string_value();
  400. std::string broadcastPrivacy =
  401. json["status"]["privacyStatus"].string_value();
  402. stream.id = boundStreamId.c_str();
  403. if (!stream.id.isEmpty() && apiYouTube->FindStream(stream.id, json)) {
  404. auto item = json["items"].array_items()[0];
  405. auto streamName = item["cdn"]["ingestionInfo"]["streamName"]
  406. .string_value();
  407. auto title = item["snippet"]["title"].string_value();
  408. auto description =
  409. item["snippet"]["description"].string_value();
  410. stream.name = streamName.c_str();
  411. stream.title = title.c_str();
  412. stream.description = description.c_str();
  413. api->SetBroadcastId(selectedBroadcast);
  414. } else {
  415. stream = {"", "", "OBS Studio Video Stream", ""};
  416. if (!apiYouTube->InsertStream(stream)) {
  417. blog(LOG_DEBUG, "No stream created.");
  418. return false;
  419. }
  420. if (!apiYouTube->BindStream(selectedBroadcast, stream.id)) {
  421. blog(LOG_DEBUG, "No stream binded.");
  422. return false;
  423. }
  424. }
  425. if (broadcastPrivacy != "private")
  426. apiYouTube->SetChatId(selectedBroadcast);
  427. else
  428. apiYouTube->ResetChat();
  429. return true;
  430. }
  431. void OBSYoutubeActions::ShowErrorDialog(QWidget *parent, QString text)
  432. {
  433. QMessageBox dlg(parent);
  434. dlg.setWindowFlags(dlg.windowFlags() & ~Qt::WindowCloseButtonHint);
  435. dlg.setWindowTitle(QTStr("YouTube.Actions.Error.Title"));
  436. dlg.setText(text);
  437. dlg.setTextFormat(Qt::RichText);
  438. dlg.setIcon(QMessageBox::Warning);
  439. dlg.setStandardButtons(QMessageBox::StandardButton::Ok);
  440. dlg.exec();
  441. }
  442. void OBSYoutubeActions::InitBroadcast()
  443. {
  444. StreamDescription stream;
  445. QMessageBox msgBox(this);
  446. msgBox.setWindowFlags(msgBox.windowFlags() &
  447. ~Qt::WindowCloseButtonHint);
  448. msgBox.setWindowTitle(QTStr("YouTube.Actions.Notify.Title"));
  449. msgBox.setText(QTStr("YouTube.Actions.Notify.CreatingBroadcast"));
  450. msgBox.setStandardButtons(QMessageBox::StandardButtons());
  451. bool success = false;
  452. auto action = [&]() {
  453. if (ui->tabWidget->currentIndex() == 0) {
  454. if (ui->checkScheduledLater->isChecked()) {
  455. success = this->StreamLaterAction(apiYouTube);
  456. } else {
  457. success = this->StreamNowAction(apiYouTube,
  458. stream);
  459. }
  460. } else {
  461. success = this->ChooseAnEventAction(apiYouTube, stream);
  462. };
  463. QMetaObject::invokeMethod(&msgBox, "accept",
  464. Qt::QueuedConnection);
  465. };
  466. QScopedPointer<QThread> thread(CreateQThread(action));
  467. thread->start();
  468. msgBox.exec();
  469. thread->wait();
  470. if (success) {
  471. if (ui->tabWidget->currentIndex() == 0) {
  472. // Stream later usecase.
  473. if (ui->checkScheduledLater->isChecked()) {
  474. QMessageBox msg(this);
  475. msg.setWindowTitle(QTStr(
  476. "YouTube.Actions.EventCreated.Title"));
  477. msg.setText(QTStr(
  478. "YouTube.Actions.EventCreated.Text"));
  479. msg.setStandardButtons(QMessageBox::Ok);
  480. msg.exec();
  481. // Close dialog without start streaming.
  482. Cancel();
  483. } else {
  484. // Stream now usecase.
  485. blog(LOG_DEBUG, "New valid stream: %s",
  486. QT_TO_UTF8(stream.name));
  487. emit ok(QT_TO_UTF8(stream.id),
  488. QT_TO_UTF8(stream.name), true, true);
  489. Accept();
  490. }
  491. } else {
  492. // Stream to precreated broadcast usecase.
  493. emit ok(QT_TO_UTF8(stream.id), QT_TO_UTF8(stream.name),
  494. autostart, autostop);
  495. Accept();
  496. }
  497. } else {
  498. // Fail.
  499. auto last_error = apiYouTube->GetLastError();
  500. if (last_error.isEmpty())
  501. last_error = QTStr("YouTube.Actions.Error.YouTubeApi");
  502. if (!apiYouTube->GetTranslatedError(last_error))
  503. last_error =
  504. QTStr("YouTube.Actions.Error.NoBroadcastCreated")
  505. .arg(last_error);
  506. ShowErrorDialog(this, last_error);
  507. }
  508. }
  509. void OBSYoutubeActions::UiToBroadcast(BroadcastDescription &broadcast)
  510. {
  511. broadcast.title = ui->title->text();
  512. // ToDo: UI warning rather than silent truncation
  513. broadcast.description = ui->description->toPlainText().left(5000);
  514. broadcast.privacy = ui->privacyBox->currentData().toString();
  515. broadcast.category.title = ui->categoryBox->currentText();
  516. broadcast.category.id = ui->categoryBox->currentData().toString();
  517. broadcast.made_for_kids = ui->yesMakeForKids->isChecked();
  518. broadcast.latency = ui->latencyBox->currentData().toString();
  519. broadcast.auto_start = ui->checkAutoStart->isChecked();
  520. broadcast.auto_stop = ui->checkAutoStop->isChecked();
  521. broadcast.dvr = ui->checkDVR->isChecked();
  522. broadcast.schedul_for_later = ui->checkScheduledLater->isChecked();
  523. broadcast.projection = ui->check360Video->isChecked() ? "360"
  524. : "rectangular";
  525. // Current time by default.
  526. broadcast.schedul_date_time = QDateTime::currentDateTimeUtc().toString(
  527. SchedulDateAndTimeFormat);
  528. }
  529. void OBSYoutubeActions::OpenYouTubeDashboard()
  530. {
  531. ChannelDescription channel;
  532. if (!apiYouTube->GetChannelDescription(channel)) {
  533. blog(LOG_DEBUG, "Could not get channel description.");
  534. ShowErrorDialog(
  535. this,
  536. apiYouTube->GetLastError().isEmpty()
  537. ? QTStr("YouTube.Actions.Error.General")
  538. : QTStr("YouTube.Actions.Error.Text")
  539. .arg(apiYouTube->GetLastError()));
  540. return;
  541. }
  542. //https://studio.youtube.com/channel/UCA9bSfH3KL186kyiUsvi3IA/videos/live?filter=%5B%5D&sort=%7B%22columnType%22%3A%22date%22%2C%22sortOrder%22%3A%22DESCENDING%22%7D
  543. QString uri =
  544. QString("https://studio.youtube.com/channel/%1/videos/live?filter=[]&sort={\"columnType\"%3A\"date\"%2C\"sortOrder\"%3A\"DESCENDING\"}")
  545. .arg(channel.id);
  546. QDesktopServices::openUrl(uri);
  547. }
  548. void OBSYoutubeActions::Cancel()
  549. {
  550. workerThread->stop();
  551. reject();
  552. }
  553. void OBSYoutubeActions::Accept()
  554. {
  555. workerThread->stop();
  556. accept();
  557. }