Thunder-Menu

Thunder-Menu Youtube GTA5

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