| 619 | } |
| 620 | |
| 621 | void SamplePlayer::DownloadYoutube(std::string url, std::string title) |
| 622 | { |
| 623 | mPlay = false; |
| 624 | if (mSample) |
| 625 | mSample->SetPlayPosition(0); |
| 626 | |
| 627 | auto tempDownloadName = ofToString(this) + "_youtube.m4a"; |
| 628 | { |
| 629 | auto file = juce::File(ofToDataPath(tempDownloadName)); |
| 630 | if (file.existsAsFile()) |
| 631 | file.deleteFile(); |
| 632 | } |
| 633 | |
| 634 | auto tempConvertedName = ofToString(this) + "_youtube.wav"; |
| 635 | { |
| 636 | auto file = juce::File(ofToDataPath(tempConvertedName)); |
| 637 | if (file.existsAsFile()) |
| 638 | file.deleteFile(); |
| 639 | } |
| 640 | |
| 641 | StringArray args; |
| 642 | args.add(UserPrefs.youtube_dl_path.Get()); |
| 643 | args.add(url); |
| 644 | args.add("--extract-audio"); |
| 645 | args.add("--audio-format"); |
| 646 | args.add("wav"); |
| 647 | args.add("--audio-quality"); |
| 648 | args.add("0"); |
| 649 | args.add("--no-progress"); |
| 650 | args.add("--ffmpeg-location"); |
| 651 | args.add(UserPrefs.ffmpeg_path.Get()); |
| 652 | args.add("-o"); |
| 653 | args.add(ofToDataPath(tempDownloadName)); |
| 654 | |
| 655 | mRunningProcessType = RunningProcessType::DownloadYoutube; |
| 656 | |
| 657 | mOnRunningProcessComplete = [this, tempConvertedName, title] |
| 658 | { |
| 659 | OnYoutubeDownloadComplete(tempConvertedName, title); |
| 660 | }; |
| 661 | |
| 662 | RunProcess(args); |
| 663 | } |
| 664 | |
| 665 | void SamplePlayer::OnYoutubeDownloadComplete(std::string filename, std::string title) |
| 666 | { |
nothing calls this directly
no test coverage detected