public static bool IsFFmpegExist() { if (FFMPEG_EXIST == null) { FFMPEG_EXIST = FFmpegHelper.IsExist() ? "True" : "False"; } return(FFMPEG_EXIST == "True"); }
public void DownloadVideo() { //GetStream Progress.StatusMsg = "GetStream..."; string Errlabel = ""; string[] TidalVideoUrls = TidalTool.getVideoDLUrls(TidalVideo.ID.ToString(), Resolution, out Errlabel); if (Errlabel.IsNotBlank()) { goto ERR_RETURN; } string TsFilePath = TidalTool.getVideoPath(OutputDir, TidalVideo, TidalAlbum, ".ts", hyphen: AddHyphen, plist: TidalPlaylist, artistBeforeTitle: ArtistBeforeTitle, addYear: AddYear); //Download Progress.StatusMsg = "Start..."; if (!(bool)M3u8Helper.Download(TidalVideoUrls, TsFilePath, ProgressNotify, Proxy: TidalTool.PROXY)) { Errlabel = "Download failed!"; goto ERR_RETURN; } //Convert FilePath = TidalTool.getVideoPath(OutputDir, TidalVideo, TidalAlbum, hyphen: AddHyphen, plist: TidalPlaylist, artistBeforeTitle: ArtistBeforeTitle, addYear: AddYear); if (!FFmpegHelper.IsExist()) { Errlabel = "FFmpeg is not exist!"; goto ERR_RETURN; } if (!FFmpegHelper.Convert(TsFilePath, FilePath)) { Errlabel = "Convert failed!"; goto ERR_RETURN; } System.IO.File.Delete(TsFilePath); //SetMetaData string sLabel = TidalTool.SetMetaData(FilePath, null, null, null, null, TidalVideo); if (sLabel.IsNotBlank()) { Errlabel = "Set metadata failed!"; goto ERR_RETURN; } Progress.SetStatus(ProgressHelper.STATUS.COMPLETE); return; ERR_RETURN: if (Progress.GetStatus() == ProgressHelper.STATUS.CANCLE) { return; } ErrlabelHeight = 15; Progress.SetStatus(ProgressHelper.STATUS.ERROR); Progress.Errmsg = Errlabel; }
public void DownloadVideo() { //GetStream Progress.StatusMsg = "GetStream..."; string Errlabel = ""; string[] TidalVideoUrls = TidalTool.getVideoDLUrls(TidalVideo.ID.ToString(), Resolution, out Errlabel); if (Errlabel.IsNotBlank()) { goto ERR_RETURN; } string TsFilePath = TidalTool.getVideoPath(OutputDir, TidalVideo, TidalAlbum, ".ts"); //Download Progress.StatusMsg = "Start..."; if (!(bool)M3u8Helper.Download(TidalVideoUrls, TsFilePath, ProgressNotify)) { Errlabel = "Download failed!"; goto ERR_RETURN; } //Convert FilePath = TidalTool.getVideoPath(OutputDir, TidalVideo, TidalAlbum); if (!FFmpegHelper.IsExist()) { Errlabel = "FFmpeg is not exist!"; goto ERR_RETURN; } if (!FFmpegHelper.Convert(TsFilePath, FilePath)) { Errlabel = "Convert failed!"; goto ERR_RETURN; } System.IO.File.Delete(TsFilePath); Progress.SetStatus(ProgressHelper.STATUS.COMPLETE); return; ERR_RETURN: if (Progress.GetStatus() == ProgressHelper.STATUS.CANCLE) { return; } ErrlabelHeight = 15; Progress.SetStatus(ProgressHelper.STATUS.ERROR); Progress.Errmsg = Errlabel; }
public void DownloadTrack() { string Errlabel = ""; //GetStream Progress.StatusMsg = "GetStream..."; StreamUrl TidalStream = TidalTool.getStreamUrl(TidalTrack.ID.ToString(), Quality, out Errlabel); if (Errlabel.IsNotBlank()) { goto ERR_RETURN; } Codec = TidalStream.Codec; Progress.StatusMsg = "GetStream success..."; //Get path FilePath = TidalTool.getTrackPath(OutputDir, TidalAlbum, TidalTrack, TidalStream.Url, AddHyphen, TidalPlaylist, artistBeforeTitle: ArtistBeforeTitle, addexplicit: AddExplict, addYear: AddYear, useTrackNumber: UseTrackNumber); //Check if song is downloaded already string CheckName = OnlyM4a ? FilePath.Replace(".mp4", ".m4a") : FilePath; if (CheckExist && System.IO.File.Exists(CheckName)) { Progress.Update(100, 100); Progress.SetStatus(ProgressHelper.STATUS.COMPLETE); return; } //Get contributors Progress.StatusMsg = "GetContributors..."; ObservableCollection <Contributor> pContributors = TidalTool.getTrackContributors(TidalTrack.ID.ToString(), out Errlabel); //To chinese if (ToChinese) { CloudMusicAlbum cloalbum = Chinese.matchAlbum(TidalAlbum.Title, TidalAlbum.Artist.Name); string chnname = Chinese.convertSongTitle(TidalTrack.Title, cloalbum); if (chnname != TidalTrack.Title) { FilePath = TidalTool.getTrackPath(OutputDir, TidalPlaylist != null ? null : TidalAlbum, TidalTrack, TidalStream.Url, AddHyphen, TidalPlaylist, chnname, artistBeforeTitle: ArtistBeforeTitle, addexplicit: AddExplict, addYear: AddYear, useTrackNumber: UseTrackNumber); TidalTrack.Title = chnname; } } //Download Progress.StatusMsg = "Start..."; for (int i = 0; i < 100 && Progress.GetStatus() != ProgressHelper.STATUS.CANCLE; i++) { if ((bool)DownloadFileHepler.Start(TidalStream.Url, FilePath, Timeout: 5 * 1000, UpdateFunc: UpdateDownloadNotify, ErrFunc: ErrDownloadNotify, Proxy:TidalTool.PROXY)) { //Decrypt if (!TidalTool.DecryptTrackFile(TidalStream, FilePath)) { Errlabel = "Decrypt failed!"; goto ERR_RETURN; } if (OnlyM4a) { if (TidalStream.Codec != "ac4" && TidalStream.Codec != "mha1") { string sNewName; if (!FFmpegHelper.IsExist()) { Errlabel = "Convert mp4 to m4a failed!(FFmpeg is not exist!)"; goto ERR_RETURN; } if (!TidalTool.ConvertMp4ToM4a(FilePath, out sNewName)) { Errlabel = "Convert mp4 to m4a failed!(No reason, Please feedback!)"; goto ERR_RETURN; } else { FilePath = sNewName; } } } //SetMetaData if (TidalAlbum == null && TidalTrack.Album != null) { string sErrcode = null; TidalAlbum = TidalTool.getAlbum(TidalTrack.Album.ID.ToString(), out sErrcode); } string sLabel = TidalTool.SetMetaData(FilePath, TidalAlbum, TidalTrack, TidalTool.getAlbumCoverPath(OutputDir, TidalAlbum, AddYear), pContributors); if (sLabel.IsNotBlank()) { Errlabel = "Set metadata failed!" + sLabel; goto ERR_RETURN; } Progress.SetStatus(ProgressHelper.STATUS.COMPLETE); return; } } Errlabel = "Download failed!"; ERR_RETURN: if (Progress.GetStatus() == ProgressHelper.STATUS.CANCLE) { return; } ErrlabelHeight = 15; Progress.SetStatus(ProgressHelper.STATUS.ERROR); Progress.Errmsg = Errlabel; }