Thunder-Menu

Thunder-Menu Youtube RDR2

Oct 11th, 2021 (edited)
3,225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 35.37 KB | None | 0 0
  1. #include "YoutubeDownloader.h"
  2. #include "nlohmann/json.hpp"
  3. #include "features/features.hpp"
  4.  
  5. #include "ExePath.h"
  6. #include "FileLogger.h"
  7.  
  8. #include "Drawing.h"
  9.  
  10. #define ShellExecute ShellExecuteW
  11. //enum class byte : unsigned char { };
  12.  
  13. // Windows Library Files:
  14. #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
  15. #pragma comment(lib, "ws2_32.lib")
  16. #pragma comment(lib, "Winmm.lib")
  17. #include <windows.h>
  18. #include <Mmsystem.h>
  19. #include <mciapi.h>
  20. #include <timeapi.h>
  21. #include <time.h>
  22. #include <cassert>
  23. #include <iterator>
  24. #include <shlobj.h>
  25. #include <Shlwapi.h> //PathRemoveFileSpecA banner
  26. #pragma comment(lib, "shlwapi.lib")//banner
  27. #include <objbase.h>
  28. #include <cstdint>
  29. #include <algorithm>
  30. #include <unordered_map>
  31. #include <mutex>
  32. #include <bitset>
  33. #include <urlmon.h>
  34. #pragma comment(lib, "urlmon.lib")
  35. #include <shellapi.h>
  36. #include <iomanip>
  37. #include <numeric>
  38. #include <direct.h>
  39. #define GetCurrentDir _getcwd
  40. #include <wchar.h>
  41. #include <errno.h>
  42. #include <tchar.h>
  43. #include <dinput.h>
  44. #include <sstream>
  45. #include <stdlib.h>
  46. #include <stdio.h>
  47. #include <string>
  48. #include <iostream>
  49. #include <fstream>
  50. #include <cstdio>
  51. #include <memory>
  52. #include <array>
  53. #include <ctime>
  54. #include <cstdlib>
  55. #include <chrono>
  56. #include <thread>
  57. #include <functional>
  58. #include <stdint.h>
  59. #include <mciapi.h>
  60. #include <stdio.h>
  61. #include <stdlib.h>
  62. #include <inttypes.h>
  63. #include <regex>
  64. #include <vector>
  65. bool ifsaved = 0;
  66. bool firstdowncheck = 1;
  67. std::string yd::szAlias = "";
  68. //#define ShellExecute ShellExecuteW
  69. std::string yd::youtubelink = "";
  70. std::string yd::outputname = "";
  71. bool yd::youtubebool = 0;
  72. namespace youdown
  73. {
  74. void to_json(nlohmann::json& j, const youdown::downyou& downyou) {
  75. j = nlohmann::json{ {"youtubelink", downyou.ytl},
  76. {"namesaved", downyou.ytn} };
  77. }
  78. void from_json(const nlohmann::json& j, youdown::downyou& downyou) {
  79. downyou.ytl = j["youtubelink"].get<std::string>();
  80. downyou.ytn = j["namesaved"].get<std::string>();
  81. }
  82. };
  83.  
  84. bool yd::timerffmpegbool = 0;
  85. int yd::timerffmpegconvert(std::string ffmpegname)
  86. {
  87. if (timerffmpegbool)
  88. {
  89. DWORD ticks = GetTickCount64();
  90. DWORD milliseconds = ticks % 1000;
  91. int getTimer = milliseconds;
  92. if (getTimer % 2500 == 0)
  93. {
  94. yd::convertto96k(ffmpegname);
  95. timerffmpegbool = 0;
  96. }
  97. }
  98. return 0;
  99. }
  100.  
  101. std::wstring Directory2::s2ws2(const std::string& str)
  102. {
  103. int size_needed = MultiByteToWideChar(CP_UTF8, 0, &str[0], (int)str.size(), NULL, 0);
  104. std::wstring wstrTo(size_needed, 0);
  105. MultiByteToWideChar(CP_UTF8, 0, &str[0], (int)str.size(), &wstrTo[0], size_needed);
  106. return wstrTo;
  107. }
  108.  
  109. std::wstring Directory2::s2ws1(const std::string& s)
  110. {
  111. int len;
  112. int slength = (int)s.length() + 1;
  113. len = MultiByteToWideChar(CP_ACP, 0, s.c_str(), slength, 0, 0);
  114. wchar_t* buf = new wchar_t[len];
  115. MultiByteToWideChar(CP_ACP, 0, s.c_str(), slength, buf, len);
  116. std::wstring r(buf);
  117. delete[] buf;
  118. return r;
  119. }
  120.  
  121. std::string Directory2::GetExeFileName2()
  122. {
  123. char buffer[MAX_PATH];
  124. GetModuleFileName(NULL, buffer, MAX_PATH);
  125. return std::string(buffer);
  126. }
  127.  
  128. std::string Directory2::GetExePath2()
  129. {
  130. std::string f = Directory2::GetExeFileName2();
  131. return f.substr(0, f.find_last_of("\\/"));
  132. }
  133.  
  134.  
  135. /*char loadsave::outfitbuffer[255];*/
  136. std::string Directory2::get_current_dir() {
  137. /*char buff[FILENAME_MAX];
  138. GetCurrentDir(buff, FILENAME_MAX);
  139. std::string current_working_dir(buff);
  140. std::stringstream stringcustoms1;
  141. std::string stringcustom1;
  142. stringcustoms1 << current_working_dir;
  143. stringcustoms1 >> stringcustom1;
  144. std::string quote = "/";
  145. std::string doublequote = "\\";
  146. std::string::size_type ir1 = stringcustom1.find(quote);
  147. if (ir1 != std::string::npos)
  148. stringcustom1.replace(ir1, quote.length(), doublequote);*/
  149. return Directory2::GetExePath2();
  150. }
  151.  
  152. int yd::convertint = 124;
  153. bool yd::converted = 0;
  154. int yd::renameffmpeg1()
  155. {
  156. std::ifstream ffmpeg;
  157. ffmpeg.open(Directory2::get_current_dir() + "\\ffmpeg.exe");
  158. if (ffmpeg)
  159. {
  160. std::string doubleslash = "\\";
  161. std::string doublequote = "\"";
  162. std::string getdirectory = Directory2::get_current_dir() + doubleslash;
  163. std::string getdirectories = doublequote + getdirectory;
  164. std::string renameffmpeg = getdirectories + "ffmpeg.exe";
  165. std::string renameffmpeg11 = renameffmpeg + doublequote;
  166. std::string renameffmpeg10 = renameffmpeg11 + " ffmpeg_.exe";
  167. std::string renameffmpeg1 = "rename " + renameffmpeg10;
  168. std::string cmd = "c:\\windows\\system32\\cmd.exe";
  169. std::string taskdirectory1 = " cmd /c " + renameffmpeg1;
  170. std::wstring progpath = Directory2::s2ws1(cmd);
  171. LPCWSTR lpprogpath = progpath.c_str();
  172. std::wstring commandd = Directory2::s2ws1(taskdirectory1);
  173. LPCWSTR lpcommand = commandd.c_str();
  174. ShellExecute(0, L"open", lpprogpath, lpcommand, 0, SW_HIDE/*SW_SHOW*/);
  175. }
  176. ffmpeg.close();
  177. }
  178. int yd::renameffmpeg2()
  179. {
  180. std::ifstream ffmpeg;
  181. ffmpeg.open(Directory2::get_current_dir() + "\\ffmpeg_.exe");
  182. if (ffmpeg)
  183. {
  184. std::string doubleslash = "\\";
  185. std::string doublequote = "\"";
  186. std::string getdirectory = Directory2::get_current_dir() + doubleslash;
  187. std::string getdirectories = doublequote + getdirectory;
  188. std::string renameffmpeg = getdirectories + "ffmpeg_.exe";
  189. std::string renameffmpeg11 = renameffmpeg + doublequote;
  190. std::string renameffmpeg10 = renameffmpeg11 + " ffmpeg.exe";
  191. std::string renameffmpeg1 = "rename " + renameffmpeg10;
  192. std::string cmd = "c:\\windows\\system32\\cmd.exe";
  193. std::string taskdirectory1 = " cmd /c " + renameffmpeg1;
  194. std::wstring progpath = Directory2::s2ws1(cmd);
  195. LPCWSTR lpprogpath = progpath.c_str();
  196. std::wstring commandd = Directory2::s2ws1(taskdirectory1);
  197. LPCWSTR lpcommand = commandd.c_str();
  198. ShellExecute(0, L"open", lpprogpath, lpcommand, 0, SW_HIDE/*SW_SHOW*/);
  199. }
  200. ffmpeg.close();
  201. }
  202.  
  203. int yd::convertto96k(std::string ffmpegname)
  204. {
  205. //ffmpeg -i test33.mp3 -b:v 1m -b:a 96k output.mp3
  206. std::string quote = "\\";
  207. std::string doublequote = "\"";
  208. std::string getdirectory = Directory2::get_current_dir() + quote;
  209. std::string getdirectories = doublequote + getdirectory;
  210. std::string Prog = "ffmpeg.exe ";
  211. std::string getdirectory2 = getdirectories + Prog;
  212. std::string myi = "-i ";
  213. std::string youtubedirectory4 = getdirectories + "ThunderMenu\\Youtube\\";
  214. std::string youtubedirectory3 = myi + youtubedirectory4;
  215. std::string youtubedirectory2 = youtubedirectory3 + ffmpegname;
  216. std::string youtubedirectory1 = "";
  217. if (converted)
  218. {
  219. youtubedirectory1 = youtubedirectory2 + ".mp3";
  220. }
  221. if (!converted)
  222. {
  223. youtubedirectory1 = youtubedirectory2 + ".tmp";
  224. }
  225. std::string youtubedirectory0 = youtubedirectory1 + doublequote;
  226. std::string youtubedirectory5 = youtubedirectory0 + " -b:v 1M -b:a ";
  227. std::string youtubedirectory55 = youtubedirectory5 + std::to_string(convertint);
  228. std::string youtubedirectory56 = youtubedirectory55 + "k ";
  229. std::string youtubedirectory6 = youtubedirectory56 + youtubedirectory4;
  230. std::string youtubedirectory7 = youtubedirectory6 + yd::outputname;
  231. std::string youtubedirectory77 = "";
  232. std::string youtubedirectory777 = "";
  233. std::string youtubedirectory8 = "";
  234. if (converted)
  235. {
  236. youtubedirectory77 = youtubedirectory7 + "Converted";
  237. youtubedirectory777 = youtubedirectory77 + std::to_string(convertint);
  238. youtubedirectory8 = youtubedirectory777 + ".mp3";
  239. }
  240. if (!converted)
  241. {
  242. youtubedirectory8 = youtubedirectory7 + ".mp3";
  243. }
  244. std::string youtubedirectory = youtubedirectory8 + doublequote;
  245. std::wstring progpath = Directory2::s2ws1(Prog);
  246. LPCWSTR lpprogpath = progpath.c_str();
  247. std::wstring commandd = Directory2::s2ws1(youtubedirectory);
  248. LPCWSTR lpcommand = commandd.c_str();
  249. ShellExecute(0, L"open", lpprogpath, lpcommand, 0, SW_HIDE);
  250. return 0;
  251. }
  252. int yd::youtubeDownloader(std::string link, std::string name)
  253. {
  254. std::string quote = "\\";
  255. std::string doublequote = "\"";
  256. std::string getdirectory = Directory2::get_current_dir() + quote;
  257. std::string getdirectories = doublequote + getdirectory;
  258. std::string Prog = "youtube-dl.exe ";
  259. std::string getdirectory2 = getdirectories + Prog;
  260. std::string youtubelnks = getdirectories + "ThunderMenu\\Youtube\\";
  261. std::string savednames = youtubelnks + yd::outputname;
  262. std::string linkurl = "https://www.youtube.com/watch?v=" + yd::youtubelink;
  263. std::string savednames2 = " -x --audio-format mp3 --output " + savednames;
  264. std::string savednames3 = savednames2 + ".tmp";
  265. std::string savednames4 = savednames3 + doublequote;
  266. std::string program = linkurl + savednames4;
  267. std::wstring progpath = Directory2::s2ws1(Prog);
  268. LPCWSTR lpprogpath = progpath.c_str();
  269. std::wstring commandd = Directory2::s2ws1(program);
  270. LPCWSTR lpcommand = commandd.c_str();
  271. ShellExecute(0, L"open", lpprogpath, lpcommand, 0, SW_HIDE);
  272. DWORD ticks = GetTickCount64();
  273. DWORD milliseconds = ticks % 1000;
  274. int getTimer = milliseconds;
  275. if (getTimer % 1500 == 0)
  276. {
  277. yd::timerffmpegbool = 1;
  278. yd::timerffmpegconvert(name);
  279. }
  280. return 0;
  281. }
  282.  
  283. void youtube_persist::save_location2(std::string link, std::string name)
  284. {
  285. youdown::downyou downyou;
  286. downyou.ytl = link;
  287. downyou.ytn = name;
  288. yd::youtubeDownloader(link, name);
  289. save2(downyou, name);
  290. }
  291.  
  292. int loadname()
  293. {
  294. yd::youtubebool = true;
  295. yd::szAlias = yd::outputname;
  296. yd::startmusicdownloadsmp3(yd::outputname);
  297. yd::start();
  298. yd::youtubebool = false;
  299. return 0;
  300. }
  301.  
  302. void youtube_persist::load_location2(std::string name)
  303. {
  304. auto locations = get_locations_json2();
  305. if (locations[name].is_null())
  306. return;
  307. auto model_attachment = locations[name].get<youdown::downyou>();
  308. yd::youtubelink = model_attachment.ytl;
  309. yd::outputname = model_attachment.ytn;
  310. loadname();
  311. }
  312.  
  313. void youtube_persist::delete_location2(std::string name)
  314. {
  315. auto locations = get_locations_json2();
  316. if (locations[name].is_null())
  317. return;
  318. locations.erase(name);
  319. save_json2(locations);
  320. }
  321.  
  322. std::vector<std::string> youtube_persist::list_locations2()
  323. {
  324. std::vector<std::string> return_value;
  325. auto json = get_locations_json2();
  326. for (auto& item : json.items())
  327. return_value.push_back(item.key());
  328. return return_value;
  329. }
  330. int resultpos222 = 0;
  331.  
  332.  
  333. std::string enterurl = "Enter Url Watch?v=";
  334. std::string namesave = "Save Name";
  335.  
  336.  
  337. //char* CharKeyboardsavename(char* windowName = "", int maxInput = 21, char* defaultText = "") {
  338. // WAIT(50);
  339. // GAMEPLAY::DISPLAY_ONSCREEN_KEYBOARD(0, "", "", defaultText, "", "", "", maxInput);
  340. // while (GAMEPLAY::UPDATE_ONSCREEN_KEYBOARD() == 0) WAIT(0);
  341. // if (!GAMEPLAY::GET_ONSCREEN_KEYBOARD_RESULT()) return ""; //Thunder
  342. // return GAMEPLAY::GET_ONSCREEN_KEYBOARD_RESULT();
  343. //}
  344.  
  345. std::string urlstring = "";
  346. void urleyboard()
  347. {
  348. settings.menu.youtubelink = 1;
  349. std::string savedkey = yd::youtubelink;
  350. if (savedkey != "")
  351. {
  352. urlstring = savedkey;
  353. }
  354. else
  355. {
  356. }
  357. }
  358.  
  359. std::string outputnamestring = "";
  360. void nameoutputleyboard()
  361. {
  362. settings.menu.youtubename = 1;
  363. std::string savekey1 = yd::outputname;
  364. if (savekey1 != "")
  365. {
  366. outputnamestring = savekey1;
  367. }
  368. else
  369. {
  370. }
  371. }
  372.  
  373. void yd::startmusicdownloadsmp3(const std::string title) {
  374. yd::szAlias = title;
  375. }
  376.  
  377. int yd::stop()
  378. {
  379. std::string szCommand;
  380. szCommand = "stop " + yd::szAlias;
  381. mciSendStringA(szCommand.c_str(), NULL, 0, 0);
  382. szCommand = "close " + yd::szAlias;
  383. mciSendStringA(szCommand.c_str(), NULL, 0, 0);
  384. yd::BgMusic(false);
  385. yd::youtubebool = false;
  386. return 0;
  387. }
  388.  
  389. int yd::start()
  390. {
  391. yd::BgMusic(yd::youtubebool);
  392. return 1;
  393. }
  394.  
  395. std::wstring yd::s2ws2(const std::string& s)
  396. {
  397. int len;
  398. int slength = (int)s.length() + 1;
  399. len = MultiByteToWideChar(CP_ACP, 0, s.c_str(), slength, 0, 0);
  400. wchar_t* buf = new wchar_t[len];
  401. MultiByteToWideChar(CP_ACP, 0, s.c_str(), slength, buf, len);
  402. std::wstring r(buf);
  403. delete[] buf;
  404. return r;
  405. }
  406.  
  407. int yd::pause()
  408. {
  409. std::string szCommand;
  410. szCommand = "pause " + yd::szAlias;
  411. mciSendStringA(szCommand.c_str(), NULL, 0, 0);
  412. return 0;
  413. }
  414.  
  415. int yd::resumeplay()
  416. {
  417. std::string szCommand;
  418. szCommand = "resume " + yd::szAlias;
  419. mciSendStringA(szCommand.c_str(), NULL, 0, 0);
  420. return 0;
  421. }
  422.  
  423. //To open* .mp3:
  424. //
  425. //mciSendString("open \"*.mp3\" type mpegvideo alias mp3", NULL, 0, NULL);
  426. //To play* .mp3:
  427. //
  428. //mciSendString("play mp3", NULL, 0, NULL);
  429. //To playand wait until the* .mp3 has finished playing :
  430. //
  431. //mciSendString("play mp3 wait", NULL, 0, NULL);
  432. //To replay(play again from start) the* .mp3:
  433. //
  434. //mciSendString("play mp3 from 0", NULL, 0, NULL);
  435. //To replayand wait until the* .mp3 has finished playing :
  436. //
  437. //mciSendString("play mp3 from 0 wait", NULL, 0, NULL);
  438. //To play the* .mp3and replay it every time it ends like a loop :
  439. //
  440. //mciSendString("play mp3 repeat", NULL, 0, NULL);
  441.  
  442.  
  443. void yd::BgMusic(bool enable)
  444. {
  445. std::string szCommand;
  446. if (enable)
  447. {
  448. std::string quoteyoutube = "\\ThunderMenu\\Youtube\\";
  449. std::string doublequote = "\"";
  450. std::string getdirectory = Directory2::get_current_dir() + quoteyoutube;
  451. //szCommand = "open \"" + GetPathffA(Pathff::ThunderMenu, true) + szAlias + ".mp3" + "\" type MPEGVideo" + " alias " + szAlias;
  452. szCommand = "open \"" + /*GetPathffA(Pathff::Youtube, true)*/getdirectory + yd::szAlias + ".mp3" + "\" type MPEGVideo" + " alias " + yd::szAlias;
  453. mciSendStringA(szCommand.c_str(), NULL, 0, 0);
  454. szCommand = "play " + yd::szAlias + " from 0 repeat";
  455. mciSendStringA(szCommand.c_str(), NULL, 0, 0);
  456. szCommand = "setaudio " + yd::szAlias + " volume to 400";
  457. mciSendStringA(szCommand.c_str(), NULL, 0, 0);
  458. }
  459. }
  460. bool vectorlist = 0;
  461. void youtube_persist::do_presentation_layer2()
  462. {
  463. if (firstdowncheck)
  464. {
  465. dlyoutube::downloading();
  466. std::ifstream ffmpeg;
  467. ffmpeg.open(Directory2::get_current_dir() + "\\ffmpeg.exe");
  468. if (ffmpeg)
  469. {
  470. firstdowncheck = 0;
  471. }
  472. else
  473. {
  474. dlyoutube::downloading2();
  475. }
  476. ffmpeg.close();
  477. }
  478. auto youtube_locations = list_locations2();
  479. static std::string selected_youtube2;
  480. int xi = 0;
  481. std::vector<char*> charVec2(youtube_locations.size(), nullptr);
  482. for (int i = 0; i < youtube_locations.size(); i++) {
  483. charVec2[i] = &youtube_locations[i][0];
  484. xi = i;
  485. }
  486. if (xi != 0)
  487. {
  488. if (Menu2::ListVector("List", charVec2, resultpos222)) {
  489. char* result2 = charVec2[resultpos222];
  490. selected_youtube2 = result2;
  491. }
  492. vectorlist = 1;
  493. }
  494. if (!ifsaved)
  495. {
  496. if (Menu::Option("Save"))
  497. {
  498.  
  499. ifsaved = 1;
  500. if (vectorlist)
  501. {
  502. redDead::Background(two);
  503.  
  504. }
  505. if (!vectorlist)
  506. {
  507. redDead::Background(one);
  508. }
  509. }
  510. }
  511. if (ifsaved)
  512. {
  513. if (Menu::Option((char*)enterurl.c_str()))
  514. {
  515. urleyboard();
  516. enterurl = urlstring;
  517. yd::youtubelink = urlstring;
  518. }
  519. if (Menu::Option((char*)namesave.c_str()))
  520. {
  521. nameoutputleyboard();
  522. namesave = outputnamestring;
  523. yd::outputname = outputnamestring;
  524. }
  525. if (Menu::Option("Add to Playlist"))
  526. {
  527. save_location2(urlstring, outputnamestring);
  528. enterurl = "Enter Url";
  529. namesave = "Save Name";
  530. ifsaved = 0;
  531. }
  532. }
  533. if (xi != 0)
  534. {
  535. if (Menu::Option("Load"))
  536. {
  537. if (!selected_youtube2.empty())
  538. {
  539. load_location2(selected_youtube2);
  540. yd::outputname = selected_youtube2;
  541. selected_youtube2.clear();
  542. }
  543. }
  544. if (Menu::Option("Stop"))
  545. {
  546. yd::stop();
  547. }
  548. if (Menu::Option("Delete"))
  549. {
  550. if (!selected_youtube2.empty())
  551. {
  552. delete_location2(selected_youtube2);
  553. selected_youtube2.clear();
  554. }
  555. }
  556. if (Menu::Option("pause"))
  557. {
  558. yd::pause();
  559. }
  560. if (Menu::Option("Resume"))
  561. {
  562. yd::resumeplay();
  563. }
  564. Menu::Toggle("Converted", yd::converted);
  565. if (yd::converted)
  566. {
  567. if (Menu::Option("Rename Ffmpeg_"))
  568. {
  569. yd::renameffmpeg1();
  570. }
  571. Menu::Int("Bitrate", yd::convertint, 1, 178);
  572. if (Menu::Option("Rename Ffmpeg"))
  573. {
  574. yd::renameffmpeg2();
  575. }
  576. if (Menu::Option("Convert"))
  577. {
  578. yd::convertto96k(yd::outputname);
  579. }
  580. }
  581. }
  582. if (yd::converted)
  583. {
  584. redDead::Background(twelve);
  585. }
  586. if (!yd::converted)
  587. {
  588. if (!vectorlist && ifsaved)
  589. {
  590. redDead::Background(three);
  591. }
  592. if (vectorlist && ifsaved)
  593. {
  594. redDead::Background(seven);
  595. }
  596. if (vectorlist && !ifsaved)
  597. {
  598. redDead::Background(eight);
  599. }
  600. if (!vectorlist && !ifsaved)
  601. {
  602. redDead::Background(one);
  603. }
  604. }
  605. }
  606.  
  607. void youtube_persist::save2(youdown::downyou downyou, std::string name)
  608. {
  609. auto json = get_locations_json2();
  610. json[name] = downyou;
  611. save_json2(json);
  612. }
  613.  
  614. void youtube_persist::save_json2(nlohmann::json json)
  615. {
  616. auto file_path = get_locations_config2();
  617. std::ofstream file(file_path, std::ios::out | std::ios::trunc);
  618. file << json.dump(4);
  619. file.close();
  620. }
  621.  
  622. nlohmann::json youtube_persist::get_locations_json2()
  623. {
  624. auto file_path = get_locations_config2();
  625. nlohmann::json locations;
  626. std::ifstream file(file_path);
  627.  
  628. if (!file.fail())
  629. file >> locations;
  630.  
  631. return locations;
  632. }
  633.  
  634. void makeyoutubefolder() {
  635. std::string ytdfolder = Directory::get_current_dir() + "\\ThunderMenu\\Youtube\\";
  636. #include <windows.h>
  637. std::wstring ytdfolderstring = functions::s2ws(ytdfolder);
  638. LPCWSTR ytdfolderlpcwstr = ytdfolderstring.c_str();
  639. if (CreateDirectoryW(ytdfolderlpcwstr, NULL))
  640. {
  641. // Directory created
  642. }
  643. else if (ERROR_ALREADY_EXISTS == GetLastError())
  644. {
  645. // Directory already exists
  646. }
  647. else
  648. {
  649. // Failed for some other reason
  650. }
  651. }
  652.  
  653. char youtubefoldchar[255];
  654. void YoutubeFolder::FolderYoutube()
  655. {
  656. std::ifstream youtubefold;
  657. youtubefold.open(Directory::get_current_dir() + "\\ThunderMenu\\Youtube\\");
  658. if (youtubefold) {
  659. youtubefold >> youtubefoldchar;
  660. }
  661. if (!youtubefold) {
  662. makeyoutubefolder();
  663. }
  664. youtubefold.close();
  665. }
  666.  
  667. std::string youtube_persist::get_locations_config2()
  668. {
  669. YoutubeFolder::FolderYoutube();
  670. auto file_path = Directory::get_current_dir();
  671. file_path += "\\ThunderMenu\\Youtube\\";
  672. file_path += "YouTubeListe.json";
  673. return file_path;
  674. }
  675.  
  676. std::string gplzip1;
  677. std::string gplzip22;
  678. std::string dlyoutube::youtubedl;
  679. int ReadLinegplzip22()
  680. {
  681. std::istringstream file(gplzip1);
  682.  
  683. std::string gpl = "youtube-dl.exe";
  684. std::string lpg = "releases/download";
  685. std::regex e("\\b(" + lpg + ")([^ ]*)" + "\\b(" + gpl + ")([& ]*)");
  686. std::string gpll;
  687. while (std::getline(file, gpll))
  688. {
  689. if (regex_search(gpll, e))
  690. gplzip22 = gpll + "\n";
  691. }
  692. return 0;
  693. }
  694. bool checkfordownload = 1;
  695. int ReadLinegplzip1()
  696. {
  697. std::string doublequote = "\"";
  698. std::ifstream file(Directory::get_current_dir() + "\\youtubedl.txt");
  699. std::string gpl = "youtube-dl.exe" + doublequote;
  700. std::string lpg = "releases/download";
  701. std::regex e("\\b(" + lpg + ")([^ ]*)" + "\\b(" + gpl + ")([& ]*)");
  702. std::string gpll;
  703. std::smatch m;
  704. std::string result;
  705. while (std::getline(file, gpll))
  706. {
  707. /*if (regex_search(gpll, e))
  708. gplzip1 = gpll + "\n";*/
  709. std::sregex_iterator next(gpll.begin(), gpll.end(), e);
  710. std::sregex_iterator end;
  711. while (next != end) {
  712. std::smatch match = *next;
  713. std::cout << match.str() << "\n";
  714. if (checkfordownload)
  715. {
  716. gplzip1 = gpll;
  717. checkfordownload = 0;
  718. }
  719. next++;
  720. }
  721. }
  722. file.close();
  723. return 0;
  724. }
  725.  
  726. int ReadLinegplzip33()
  727. {
  728. std::istringstream file(dlyoutube::youtubedl);
  729. std::string lpg = "youtube-dl.exe";
  730. std::regex e{ "\\b" + lpg + "\\b" };
  731. /*std::regex e("\\b(" + lpg + ")([^ ]*)");*/
  732. std::string gpll;
  733. while (std::getline(file, gpll))
  734. {
  735. if (regex_search(gpll, e))
  736. dlyoutube::youtubedl = gpll + "\n";
  737. }
  738. return 0;
  739. }
  740. int dlyoutube::downloading()
  741. {
  742. std::ifstream youtubedll;
  743. youtubedll.open(Directory::get_current_dir() + "\\youtube-dl.exe");
  744. if (!youtubedll)
  745. {
  746. ////https://github.com/ytdl-org/youtube-dl/releases/download/2021.04.17/youtube-dl.exe
  747. //std::string dwnld_URL = "https://github.com/ytdl-org/youtube-dl/releases/download/2021.02.10/youtube-dl.exe";
  748. std::string dwnld_URL = "https://github.com/ytdl-org/youtube-dl/releases/";
  749. /*std::string savepath = Directory::get_current_dir() + "\\ffmpeg.zip";*/
  750. std::string savepath = Directory::get_current_dir() + "\\youtubedl.txt";
  751. std::wstring downloadfile = functions::s2ws(dwnld_URL);
  752. LPCWSTR downloadingfile = downloadfile.c_str();
  753. std::wstring savefile = functions::s2ws(savepath);
  754. LPCWSTR savingfile = savefile.c_str();
  755. /*URLDownloadToFile(NULL, dwnld_URL.c_str(), savepath.c_str(), 0, NULL);*/
  756. URLDownloadToFileW(NULL, downloadingfile, savingfile, 0, NULL);
  757. ReadLinegplzip1();
  758. std::string taskdirectory2 = Directory::get_current_dir() + "\\youtubedlurl.txt";
  759. std::ofstream repbegtext(taskdirectory2);
  760. if (repbegtext.is_open())
  761. {
  762. std::string doublequote = "\"";
  763. std::string ahref = "<a href=" + doublequote;
  764. std::string https = " https";
  765. std::string githubcom = https + "://github.com";
  766. std::string::size_type rep = gplzip1.find(ahref);
  767. if (rep != std::string::npos)
  768. gplzip1.replace(rep, ahref.length(), githubcom);
  769. std::string newline = "\n";
  770. size_t pos = gplzip1.find(doublequote);
  771. while (pos != std::string::npos)
  772. {
  773. gplzip1.replace(pos, doublequote.size(), newline);
  774. pos = gplzip1.find(doublequote, pos + newline.size());
  775. }
  776. ReadLinegplzip22();
  777. repbegtext << gplzip22;
  778. }
  779. repbegtext.close();
  780. std::string dwnld_URL2 = gplzip22;
  781. std::string savepath2 = Directory::get_current_dir() + "\\youtube-dl.exe";
  782. std::wstring downloadfile2 = functions::s2ws(dwnld_URL2);
  783. LPCWSTR downloadingfile2 = downloadfile2.c_str();
  784. std::wstring savefile2 = functions::s2ws(savepath2);
  785. LPCWSTR savingfile2 = savefile2.c_str();
  786. URLDownloadToFileW(NULL, downloadingfile2, savingfile2, 0, NULL);
  787. }
  788. youtubedll.close();
  789. return 0;
  790. }
  791.  
  792. bool checkfordownload2 = 1;
  793. std::string gplzip;
  794. int ReadLinegplzip()
  795. {
  796. std::ifstream file(Directory::get_current_dir() + "\\ffmpeg.txt");
  797. std::string gpl = "-win64-gpl.zip";
  798. std::string lpg = "releases/download/autobuild-";
  799. std::regex e("\\b(" + lpg + ")([^ ]*)" + "\\b(" + gpl + ")([& ]*)");
  800. std::string gpll;
  801. while (std::getline(file, gpll))
  802. {
  803. std::sregex_iterator next(gpll.begin(), gpll.end(), e);
  804. std::sregex_iterator end;
  805. while (next != end) {
  806. std::smatch match = *next;
  807. std::cout << match.str() << "\n";
  808. if (checkfordownload2)
  809. {
  810. gplzip = gpll;
  811. checkfordownload2 = 0;
  812. }
  813. next++;
  814. }
  815. }
  816.  
  817. file.close();
  818. return 0;
  819. }
  820.  
  821. std::string gplzip2;
  822. int ReadLinegplzip2()
  823. {
  824. std::istringstream file(gplzip);
  825. std::string gpl = "-win64-gpl.zip";
  826. std::string lpg = "releases/download/autobuild-";
  827. std::regex e("\\b(" + lpg + ")([^ ]*)" + "\\b(" + gpl + ")([& ]*)");
  828. std::string gpll;
  829. while (std::getline(file, gpll))
  830. {
  831. if (regex_search(gpll, e))
  832. gplzip2 = gpll + "\n";
  833. }
  834. return 0;
  835. }
  836.  
  837. std::string ffmpeg::gplzip3;
  838. int ReadLinegplzip3()
  839. {
  840. std::istringstream file(ffmpeg::gplzip3);
  841. std::string lpg = "ffmpeg-N-";
  842. std::regex e{ "\\b" + lpg + "\\b" };
  843. std::string gpll;
  844. while (std::getline(file, gpll))
  845. {
  846. if (regex_search(gpll, e))
  847. ffmpeg::gplzip3 = gpll + "\n";
  848. }
  849. return 0;
  850. }
  851.  
  852. int deleteforlderffmpeg()
  853. {
  854. std::string doubleslash = "\\";
  855. std::string doublequote = "\"";
  856. std::string taskdirectory = Directory::get_current_dir() + doubleslash;
  857. std::string cmd = "c:\\windows\\system32\\cmd.exe";
  858. std::string taskdirectory1 = " /c rmdir /s /q " + doublequote;
  859. std::string taskdirectory2 = taskdirectory1 + taskdirectory;
  860. std::string taskdirectory3 = "ffmpeg\\" + doublequote;
  861. std::string taskdirectory4 = taskdirectory2 + taskdirectory3;
  862. std::wstring progpath = functions::s2ws(cmd);
  863. LPCWSTR lpprogpath = progpath.c_str();
  864. std::wstring commandd = functions::s2ws(taskdirectory4);
  865. LPCWSTR lpcommand = commandd.c_str();
  866. ShellExecute(0, L"open", lpprogpath, lpcommand, 0, SW_HIDE/*SW_SHOW*/);
  867. return 0;
  868. }
  869. int deletearchiveffmpeg()
  870. {
  871. std::string doubleslash = "\\";
  872. std::string doublequote = "\"";
  873. std::string taskdirectory = Directory::get_current_dir() + doubleslash;
  874. std::string cmd = "c:\\windows\\system32\\cmd.exe";
  875. std::string taskdirectory1 = " /c del /s /q ";
  876. std::string taskdirectory2 = taskdirectory1 + taskdirectory;
  877. std::string taskdirectory3 = "ffmpeg.zip";
  878. std::string taskdirectory4 = taskdirectory2 + taskdirectory3;
  879. std::wstring progpath = functions::s2ws(cmd);
  880. LPCWSTR lpprogpath = progpath.c_str();
  881. std::wstring commandd = functions::s2ws(taskdirectory4);
  882. LPCWSTR lpcommand = commandd.c_str();
  883. ShellExecute(0, L"open", lpprogpath, lpcommand, 0, SW_HIDE/*SW_SHOW*/);
  884. deleteforlderffmpeg();
  885. return 0;
  886. }
  887. int powershellExecutionPolicy()
  888. {
  889. std::string doubleslash = "\\";
  890. std::string doublequote = "\"";
  891. std::string taskdirectory = Directory::get_current_dir() + doubleslash;
  892. std::string cmd = "c:\\windows\\system32\\cmd.exe";
  893. std::string taskdirectory1 = " cmd /c powershell Set-ExecutionPolicy -Scope CurrentUser Unrestricted && exit";
  894. std::wstring progpath = functions::s2ws(cmd);
  895. LPCWSTR lpprogpath = progpath.c_str();
  896. std::wstring commandd = functions::s2ws(taskdirectory1);
  897. LPCWSTR lpcommand = commandd.c_str();
  898. ShellExecute(0, L"open", lpprogpath, lpcommand, 0, SW_HIDE/*SW_SHOW*/);
  899. return 0;
  900. }
  901.  
  902. int extractffmpeg()
  903. {
  904. powershellExecutionPolicy();
  905. std::string doubleslash = "\\";
  906. std::string doublequote = "\"";
  907. std::string taskdirectory = Directory::get_current_dir() + doubleslash;
  908. std::string cmd = "c:\\windows\\system32\\cmd.exe";
  909. std::string taskdirectory2 = " /c powershell Expand-Archive -Path " + taskdirectory;
  910. std::string taskdirectory3 = taskdirectory2 + "ffmpeg.zip ";
  911. std::wstring progpath = functions::s2ws(cmd);
  912. LPCWSTR lpprogpath = progpath.c_str();
  913. std::string namesfiles0 = "-DestinationPath " + taskdirectory;
  914. std::string namesfiles1 = namesfiles0 + "ffmpeg\\";
  915. std::string namesandfiles = taskdirectory3 + namesfiles1;
  916. std::wstring commandd = functions::s2ws(namesandfiles);
  917. LPCWSTR lpcommand = commandd.c_str();
  918. ShellExecute(0, L"open", lpprogpath, lpcommand, 0, SW_HIDE);
  919. return 0;
  920. }
  921.  
  922. int moveffmpeg()
  923. {
  924. std::string zipgpl = "";
  925. std::ifstream ffmpeg;
  926. ffmpeg.open(Directory::get_current_dir() + "\\ffmpegfolder.txt");
  927. if (ffmpeg)
  928. {
  929. ffmpeg >> zipgpl;
  930. }
  931. ffmpeg.close();
  932. std::string doubleslash = "\\";
  933. std::string doublequote = "\"";
  934. std::string taskdirectory = Directory::get_current_dir() + doubleslash;
  935. std::string cmd = "c:\\windows\\system32\\cmd.exe";
  936. std::string taskdirectory2 = " /c move " + taskdirectory;
  937. std::string taskdirectory3 = taskdirectory2 + "ffmpeg\\";
  938. std::string taskdirectory4 = taskdirectory3 + zipgpl;
  939. std::string taskdirectory5 = taskdirectory4 + "\\bin\\ffmpeg.exe ";
  940. std::wstring progpath = functions::s2ws(cmd);
  941. LPCWSTR lpprogpath = progpath.c_str();
  942. std::string namesandfiles = taskdirectory5 + taskdirectory;
  943. std::wstring commandd = functions::s2ws(namesandfiles);
  944. LPCWSTR lpcommand = commandd.c_str();
  945. ShellExecute(0, L"open", lpprogpath, lpcommand, 0, SW_HIDE/*SW_SHOW*/);
  946. return 0;
  947. }
  948.  
  949. int moveffplay()
  950. {
  951. std::string zipgpl = "";
  952. std::ifstream ffmpeg;
  953. ffmpeg.open(Directory::get_current_dir() + "\\ffmpegfolder.txt");
  954. if (ffmpeg)
  955. {
  956. ffmpeg >> zipgpl;
  957. }
  958. ffmpeg.close();
  959. std::string doubleslash = "\\";
  960. std::string doublequote = "\"";
  961. std::string taskdirectory = Directory::get_current_dir() + doubleslash;
  962. std::string cmd = "c:\\windows\\system32\\cmd.exe";
  963. std::string taskdirectory2 = " /c move " + taskdirectory;
  964. std::string taskdirectory3 = taskdirectory2 + "ffmpeg\\";
  965. std::string taskdirectory4 = taskdirectory3 + zipgpl;
  966. std::string taskdirectory5 = taskdirectory4 + "\\bin\\ffplay.exe ";
  967. std::wstring progpath = functions::s2ws(cmd);
  968. LPCWSTR lpprogpath = progpath.c_str();
  969. std::string namesandfiles = taskdirectory5 + taskdirectory;
  970. std::wstring commandd = functions::s2ws(namesandfiles);
  971. LPCWSTR lpcommand = commandd.c_str();
  972. ShellExecute(0, L"open", lpprogpath, lpcommand, 0, SW_HIDE/*SW_SHOW*/);
  973. return 0;
  974. }
  975.  
  976. int moveffprobe()
  977. {
  978. std::string zipgpl = "";
  979. std::ifstream ffmpeg;
  980. ffmpeg.open(Directory::get_current_dir() + "\\ffmpegfolder.txt");
  981. if (ffmpeg)
  982. {
  983. ffmpeg >> zipgpl;
  984. }
  985. ffmpeg.close();
  986. std::string doubleslash = "\\";
  987. std::string doublequote = "\"";
  988. std::string taskdirectory = Directory::get_current_dir() + doubleslash;
  989. std::string cmd = "c:\\windows\\system32\\cmd.exe";
  990. std::string taskdirectory2 = " /c move " + taskdirectory;
  991. std::string taskdirectory3 = taskdirectory2 + "ffmpeg\\";
  992. std::string taskdirectory4 = taskdirectory3 + zipgpl;
  993. std::string taskdirectory5 = taskdirectory4 + "\\bin\\ffprobe.exe ";
  994. std::wstring progpath = functions::s2ws(cmd);
  995. LPCWSTR lpprogpath = progpath.c_str();
  996. std::string namesandfiles = taskdirectory5 + taskdirectory;
  997. std::wstring commandd = functions::s2ws(namesandfiles);
  998. LPCWSTR lpcommand = commandd.c_str();
  999. ShellExecute(0, L"open", lpprogpath, lpcommand, 0, SW_HIDE/*SW_SHOW*/);
  1000. return 0;
  1001. }
  1002.  
  1003. bool boolyd1 = 1;
  1004. bool yd::loopbool = 0;
  1005. int yd::looptimer()
  1006. {
  1007. if (yd::loopbool)
  1008. {
  1009. if (boolyd1)
  1010. {
  1011. DWORD ticks = GetTickCount64();
  1012. DWORD milliseconds = ticks % 1000;
  1013. int getTimer = milliseconds;
  1014. if (getTimer % 1500 == 0)
  1015. {
  1016. extractffmpeg();
  1017. boolyd1 = 0;
  1018. }
  1019. }
  1020. if (!boolyd1)
  1021. {
  1022. DWORD ticks = GetTickCount64();
  1023. DWORD milliseconds = ticks % 1000;
  1024. int getTimer = milliseconds;
  1025. if (getTimer % 2000 == 0)
  1026. {
  1027. moveffmpeg();
  1028. moveffplay();
  1029. moveffprobe();
  1030. yd::loopbool = 0;
  1031. }
  1032. }
  1033. }
  1034. return 0;
  1035. }
  1036.  
  1037. int moveffprog()
  1038. {
  1039. yd::loopbool = 1;
  1040. if (yd::loopbool)
  1041. {
  1042. yd::looptimer();
  1043. }
  1044. return 0;
  1045. }
  1046.  
  1047. int dlyoutube::downloading2()
  1048. {
  1049. std::ifstream ffmpeg;
  1050. ffmpeg.open(Directory::get_current_dir() + "\\ffmpeg.zip");
  1051. if (!ffmpeg)
  1052. {
  1053. /*std::string dwnld_URL = "https://github.com/BtbN/FFmpeg-Builds/releases/download/autobuild-2021-04-09-12-38/ffmpeg-N-101901-gb593abda6c-win64-gpl.zip";*/
  1054. std::string dwnld_URL = "https://github.com/BtbN/FFmpeg-Builds/releases";
  1055. std::string savepath = Directory::get_current_dir() + "\\ffmpeg.txt";
  1056. std::wstring downloadfile = functions::s2ws(dwnld_URL);
  1057. LPCWSTR downloadingfile = downloadfile.c_str();
  1058. std::wstring savefile = functions::s2ws(savepath);
  1059. LPCWSTR savingfile = savefile.c_str();
  1060. URLDownloadToFileW(NULL, downloadingfile, savingfile, 0, NULL);
  1061. ReadLinegplzip();
  1062. std::string taskdirectory2 = Directory::get_current_dir() + "\\ffmpegurl.txt";
  1063. std::ofstream repbegtext(taskdirectory2);
  1064. if (repbegtext.is_open())
  1065. {
  1066. std::string doublequote = "\"";
  1067. std::string ahref = "<a href=" + doublequote;
  1068. std::string https = " https";
  1069. std::string githubcom = https + "://github.com";
  1070. std::string::size_type rep = gplzip.find(ahref);
  1071. if (rep != std::string::npos)
  1072. gplzip.replace(rep, ahref.length(), githubcom);
  1073. std::string newline = "\n";
  1074. size_t pos = gplzip.find(doublequote);
  1075. while (pos != std::string::npos)
  1076. {
  1077. gplzip.replace(pos, doublequote.size(), newline);
  1078. pos = gplzip.find(doublequote, pos + newline.size());
  1079. }
  1080. ReadLinegplzip2();
  1081. repbegtext << gplzip2;
  1082. }
  1083. repbegtext.close();
  1084. std::string dwnld_URL2 = gplzip2;
  1085. std::string savepath2 = Directory::get_current_dir() + "\\ffmpeg.zip";
  1086. std::wstring downloadfile2 = functions::s2ws(dwnld_URL2);
  1087. LPCWSTR downloadingfile2 = downloadfile2.c_str();
  1088. std::wstring savefile2 = functions::s2ws(savepath2);
  1089. LPCWSTR savingfile2 = savefile2.c_str();
  1090. URLDownloadToFileW(NULL, downloadingfile2, savingfile2, 0, NULL);
  1091. std::string line = "\n";
  1092. std::string ffmpegn = "ffmpeg-N";
  1093. std::string ffmpegnew = line + "ffmpeg-N";
  1094. std::string wingpl = "-win64-gpl" + line;
  1095. std::string wingplzip = "-win64-gpl.zip";
  1096. ffmpeg::gplzip3 = gplzip2;
  1097. std::string::size_type rep1 = ffmpeg::gplzip3.find(ffmpegn);
  1098. if (rep1 != std::string::npos)
  1099. ffmpeg::gplzip3.replace(rep1, ffmpegn.length(), ffmpegnew);
  1100.  
  1101. std::string::size_type rep2 = ffmpeg::gplzip3.find(wingplzip);
  1102. if (rep2 != std::string::npos)
  1103. ffmpeg::gplzip3.replace(rep2, wingplzip.length(), wingpl);
  1104. std::string taskdirectory3 = Directory::get_current_dir() + "\\ffmpegfolder.txt";
  1105. std::ofstream repbegtext2(taskdirectory3);
  1106. if (repbegtext2.is_open())
  1107. {
  1108. ReadLinegplzip3();
  1109. repbegtext2 << ffmpeg::gplzip3;
  1110. }
  1111. repbegtext2.close();
  1112. }
  1113. ffmpeg.close();
  1114. moveffprog();
  1115. return 0;
  1116. }
  1117. //.h
  1118. #pragma once
  1119. #include <string>
  1120. #include "../rdr2_internal/main/rdr2_main.hpp"
  1121. #include "../rdr2_internal/nlohmann/json.hpp"
  1122.  
  1123. class yd
  1124. {
  1125. public:
  1126. static void BgMusic(bool enable);
  1127. static int youtubeDownloader(std::string link, std::string name);
  1128. static std::string youtubelink;
  1129. static std::string outputname;
  1130. static bool youtubebool;
  1131. static int start();
  1132. static int stop();
  1133. static void startmusicdownloadsmp3(const std::string title);
  1134. static std::string szAlias;
  1135. static int looptimer();
  1136. static bool loopbool;
  1137. static int convertint;
  1138. static int convertto96k(std::string ffmpegname);
  1139. static bool timerffmpegbool;
  1140. static int timerffmpegconvert(std::string ffmpegname);
  1141. static int pause();
  1142. static int resumeplay();
  1143. static std::wstring s2ws2(const std::string& s);
  1144. static bool converted;
  1145. static int renameffmpeg1();
  1146. static int renameffmpeg2();
  1147. };
  1148. namespace youdown
  1149. {
  1150. struct downyou
  1151. {
  1152. std::string ytl;
  1153. std::string ytn;
  1154. };
  1155.  
  1156. void to_json(nlohmann::json& j, const downyou& youdown);
  1157. void from_json(const nlohmann::json& j, downyou& youdown);
  1158. }
  1159.  
  1160. class youtube_persist
  1161. {
  1162. public:
  1163. static void do_presentation_layer2();
  1164. private:
  1165. static void save_location2(std::string link, std::string name);
  1166. static void load_location2(std::string name);
  1167. static void delete_location2(std::string name);
  1168. static std::vector<std::string> list_locations2();
  1169. static void save2(youdown::downyou downyou, std::string name);
  1170. static void save_json2(nlohmann::json json);
  1171. static nlohmann::json get_locations_json2();
  1172. static std::string get_locations_config2();
  1173. };
  1174. class dlyoutube
  1175. {
  1176. public:
  1177. static int downloading();
  1178. static int downloading2();
  1179. static std::string youtubedl;
  1180. };
  1181.  
  1182. class ffmpeg
  1183. {
  1184. public:
  1185. static std::string gplzip3;
  1186. };
  1187.  
  1188. namespace Directory2
  1189. {
  1190. extern std::wstring s2ws1(const std::string& s);
  1191. extern std::wstring s2ws2(const std::string& str);
  1192. extern std::string get_current_dir();
  1193. extern std::string GetExeFileName2();
  1194. extern std::string GetExePath2();
  1195. }
  1196. namespace YoutubeFolder
  1197. {
  1198. extern void FolderYoutube();
  1199. }
  1200. void makeyoutubefolder();
  1201.  
  1202. //features
  1203.  
  1204. if (settings.menu.youtubelink) {
  1205. static std::string ped_;
  1206. if (ped_.empty()) {
  1207. ped_ = helpers::get_keyboard_input("save youtube link");
  1208. }
  1209. else {
  1210. static std::string amount;
  1211. auto pos = ped_.find("-");
  1212. if (pos != std::string::npos) {
  1213. amount = ped_.substr(pos + 1);
  1214. ped_.erase(pos, ped_.size());
  1215. }
  1216. else {
  1217. amount = "1";
  1218. }
  1219.  
  1220. auto max_it = std::stoi(amount.c_str());
  1221. for (int i = 0; i < max_it; i++)
  1222. yd::youtubelink = ped_.c_str();
  1223.  
  1224. ped_.clear();
  1225. settings.menu.youtubelink = false;
  1226. }
  1227. }
  1228.  
  1229. if (settings.menu.youtubename) {
  1230. static std::string ped_;
  1231. if (ped_.empty()) {
  1232. ped_ = helpers::get_keyboard_input("save youtube name");
  1233. }
  1234. else {
  1235. static std::string amount;
  1236. auto pos = ped_.find("-");
  1237. if (pos != std::string::npos) {
  1238. amount = ped_.substr(pos + 1);
  1239. ped_.erase(pos, ped_.size());
  1240. }
  1241. else {
  1242. amount = "1";
  1243. }
  1244.  
  1245. auto max_it = std::stoi(amount.c_str());
  1246. for (int i = 0; i < max_it; i++)
  1247. yd::outputname = ped_.c_str();
  1248.  
  1249. ped_.clear();
  1250. settings.menu.youtubename = false;
  1251. }
  1252. }
  1253.  
  1254. Thunder-Menu Youtube RDR2
  1255. https://pastebin.com/Lg7LKR0X
  1256. Thunder-Menu Youtube GTA5
  1257. https://pastebin.com/5fv3ywBu
Add Comment
Please, Sign In to add comment