public async void Confirm() { Errlabel = ""; if (Username.IsBlank() || Password.IsBlank()) { Errlabel = "Username or password is err!"; return; } Config.AddHistoryAccount(Username, Password); ShowMainPage(false); //Proxy TidalTool.PROXY = ProxyEnable ? new HttpHelper.ProxyInfo(ProxyHost, ProxyPort, ProxyUser, ProxyPwd) : null; bool bRet = await Task.Run(() => { return(TidalTool.login(Username, Password)); }); if (!bRet) { Errlabel = "Login Err! " + TidalTool.loginErrlabel; } else { //DEBUG //eObjectType eType = eObjectType.None; //object obj = Tidal.TidalTool.tryGet("19297475", out eType, eObjectType.ALBUM); //Artist obj = (Artist)Tidal.TidalTool.tryGet("eason chan", out eType, eObjectType.ARTIST); VMMain.SetLogViewModel(this); Manager.ShowWindow(VMMain); RequestClose(); } ShowMainPage(true); return; }
public void Logout() { TidalTool.logout(); ThreadTool.Close(); Manager.ShowWindow(VMLogin); RequestClose(); }
public void RefreshSetting() { OutputDir = Config.OutputDir(); OnlyM4a = Config.OnlyM4a(); AddHyphen = Config.AddHyphen(); ToChinese = Config.ToChinese(); CheckExist = Config.CheckExist(); ArtistBeforeTitle = Config.ArtistBeforeTitle(); ThreadNum = AIGS.Common.Convert.ConverStringToInt(Config.ThreadNum()) - 1; SearchNum = AIGS.Common.Convert.ConverStringToInt(Config.SearchNum()) / 10 - 1; QualityList = TidalTool.getQualityList(); ResolutionList = TidalTool.getResolutionList(); SelectQualityIndex = QualityList.IndexOf(Config.Quality().ToUpper()); SelectResolutionIndex = ResolutionList.IndexOf(Config.Resolution().ToUpper()); if (SelectQualityIndex < 0) { SelectQualityIndex = 0; } if (SelectResolutionIndex < 0) { SelectResolutionIndex = 0; } if (ThreadNum < 0) { ThreadNum = 0; } if (SearchNum < 0 || SearchNum > 5) { SearchNum = 0; } }
public DownloadItem(int index, Track track = null, Video video = null, Album album = null, Playlist plist = null) { TidalPlaylist = plist; TidalAlbum = album; TidalVideo = video; TidalTrack = track; Quality = TidalTool.getQuality(Config.Quality()); Resolution = TidalTool.getResolution(Config.Resolution()); OutputDir = Config.OutputDir(); Index = index; Progress = new ProgressHelper(); OnlyM4a = Config.OnlyM4a(); AddHyphen = Config.AddHyphen(); Own = album == null?null : album.Title; ToChinese = Config.ToChinese(); CheckExist = Config.CheckExist(); ArtistBeforeTitle = Config.ArtistBeforeTitle(); if (TidalTrack != null) { Title = track.Title; sType = "MusicCircle"; } else { Title = video.Title; sType = "PlayCircle"; } }
public void Confirm() { Config.ThreadNum((ThreadNum + 1).ToString()); Config.SearchNum(((SearchNum + 1) * 10).ToString()); Config.OnlyM4a(OnlyM4a.ToString()); Config.AddExplicitTag(AddExplicitTag.ToString()); Config.SaveCovers(SaveCovers.ToString()); Config.IncludeEP(IncludeEPSingle.ToString()); Config.ToChinese(ToChinese.ToString()); Config.CheckExist(CheckExist.ToString()); Config.ArtistBeforeTitle(ArtistBeforeTitle.ToString()); Config.AddHyphen(AddHyphen.ToString()); Config.AddYear(AddYearIndex); Config.Quality(QualityList[SelectQualityIndex].ToLower()); Config.Resolution(ResolutionList[SelectResolutionIndex]); Config.OutputDir(OutputDir); Config.UseTrackNumber(UseTrackNumber.ToString()); Config.MaxFileName(CheckMaxName(MaxFileName)); Config.MaxDirName(CheckMaxName(MaxDirName)); Config.AddAlbumIDBeforeFolder(AddAlbumIDBeforeFolder.ToString()); TidalTool.SetSearchMaxNum(int.Parse(Config.SearchNum())); ThreadTool.SetThreadNum(ThreadNum + 1); RequestClose(); }
public async void Search(string SearchStr) { ShowCoverFlow = Visibility.Hidden; if (SearchStr.IsBlank()) { Growl.Error("Search string is empty!", "SearchMsg"); return; } //Search ShowWait(); object SearchObj = await Task.Run(() => { return(TidalTool.tryGet(SearchStr, out SearchType)); }); if (SearchType == eObjectType.None) { Growl.Error("Search Err!", "SearchMsg"); } else if (SearchType == Tidal.eObjectType.SEARCH) { SearchResult = ((Tidal.SearchResult)SearchObj); ShowDetailView = Visibility.Hidden; } else { LoadDetail(SearchObj); ShowDetailView = Visibility.Visible; } ShowWait(false); }
public async void Confirm() { string ResultID = null; if (SelectIndex >= 0) { if (bCheckArtist && SearchInfo.Artists.Count > 0) { ResultID = SearchInfo.Artists[SelectIndex].ID.ToString(); ResultType = eObjectType.ARTIST; } if (bCheckAlbum && SearchInfo.Albums.Count > 0) { ResultID = SearchInfo.Albums[SelectIndex].ID.ToString(); ResultType = eObjectType.ALBUM; } if (bCheckTrack && SearchInfo.Tracks.Count > 0) { ResultID = SearchInfo.Tracks[SelectIndex].ID.ToString(); ResultType = eObjectType.TRACK; } if (bCheckVideo && SearchInfo.Videos.Count > 0) { ResultID = SearchInfo.Videos[SelectIndex].ID.ToString(); ResultType = eObjectType.VIDEO; } ShowWait = Visibility.Visible; await Task.Run(() => { ResultObject = TidalTool.tryGet(ResultID, out ResultType, ResultType); }); } RequestClose(); }
public async void Confirm() { Errlabel = ""; if (Username.IsBlank() || Password.IsBlank()) { Errlabel = "Username or password is err!"; return; } Config.AddHistoryAccount(Username, Password); ShowMainPage(false); bool bRet = await Task.Run(() => { return(TidalTool.login(Username, Password)); }); if (!bRet) { Errlabel = "Login Err!"; } else { VMMain.SetLogViewModel(this); Manager.ShowWindow(VMMain); RequestClose(); } ShowMainPage(true); return; }
public async void Confirm() { Errlabel = ""; if (Username.IsBlank() || Password.IsBlank()) { Errlabel = "Username or password is err!"; return; } Config.AddHistoryAccount(Username, Password); ShowMainPage(false); //Proxy TidalTool.PROXY = ProxyEnable ? new HttpHelper.ProxyInfo(ProxyHost, ProxyPort, ProxyUser, ProxyPwd) : null; bool bRet = await Task.Run(() => { return(TidalTool.login(Username, Password)); }); if (!bRet) { Errlabel = "Login Err!"; } else { //DEBUG //eObjectType eType = eObjectType.None; //Tidal.TidalTool.tryGet("36ea71a8-445e-41a4-82ab-6628c581535d", out eType); VMMain.SetLogViewModel(this); Manager.ShowWindow(VMMain); RequestClose(); } ShowMainPage(true); return; }
public MainViewModel(IWindowManager manager, SettingViewModel setting, AboutViewModel about, InfoViewModel albuminfo, SearchViewModel search, DllistViewModel dllist) { Manager = manager; VMSetting = setting; VMAbout = about; VMInfo = albuminfo; VMSearch = search; VMDllist = dllist; ThreadTool.SetThreadNum(int.Parse(Config.ThreadNum())); UpdateThread = new Thread(ThreadUpdateFunc); UpdateThread.IsBackground = true; UpdateThread.Start(); TidalTool.SetSearchMaxNum(int.Parse(Config.SearchNum())); ////test //CloudMusicAlbum album = Chinese.matchAlbum("Won't Cry", "Jay Chou"); //string sName = Chinese.convertSongTitle("Won't Cry", album); //VMDllist.Convert(); //return; }
public void ThreadFunc(object[] data) { while (true) { for (int i = 0; i < Items.Count; i++) { if (Items[i].Status != "Wait") { continue; } Items[i].Status = "Parse"; //Get eObjectType eType; object Data = TidalTool.tryGet(Items[i].Name, out eType, Items[i].Type); //Result if (eType == eObjectType.None || Data == null) { Items[i].Status = "Err"; } else { Items[i].Type = eType; Items[i].Data = Data; Items[i].Status = "Success"; } } Thread.Sleep(3000); } }
public MainListItemViewModel(object data, BindableCollection <MainListItemViewModel> parents) { AddYear = Config.AddYear(); Parents = parents; DLItemList = new ObservableCollection <DownloadItem>(); if (data.GetType() == typeof(Album)) { Album album = (Album)data; Title = album.Title; BasePath = TidalTool.getAlbumFolder(Config.OutputDir(), album, AddYear); Desc = string.Format("by {0}-{1} Tracks-{2} Videos-{3}", album.Artist.Name, TimeHelper.ConverIntToString(album.Duration), album.NumberOfTracks, album.NumberOfVideos); Cover = AIGS.Common.Convert.ConverByteArrayToBitmapImage(album.CoverData); AddAlbum(album); } else if (data.GetType() == typeof(Video)) { Video video = (Video)data; Title = video.Title; BasePath = TidalTool.getVideoFolder(Config.OutputDir()); Desc = string.Format("by {0}-{1}", video.Artist.Name, TimeHelper.ConverIntToString(video.Duration)); Cover = AIGS.Common.Convert.ConverByteArrayToBitmapImage(video.CoverData); DLItemList.Add(new DownloadItem(DLItemList.Count + 1, null, video, null)); } else if (data.GetType() == typeof(Artist)) { Artist artist = (Artist)data; Title = artist.Name; BasePath = TidalTool.getArtistFolder(Config.OutputDir(), artist); Desc = string.Format("by {0} Albums-{1}", artist.Name, artist.Albums.Count); Cover = AIGS.Common.Convert.ConverByteArrayToBitmapImage(artist.CoverData); foreach (var item in artist.Albums) { AddAlbum(item); } } else if (data.GetType() == typeof(Playlist)) { Playlist plist = (Playlist)data; Title = plist.Title; BasePath = TidalTool.getPlaylistFolder(Config.OutputDir(), plist); //Desc = string.Format("by {0}-{1} Tracks-{2} Videos-{3}", plist.Created, TimeHelper.ConverIntToString(plist.Duration), plist.NumberOfTracks, plist.NumberOfVideos); Desc = string.Format("{0} Tracks-{1} Videos-{2}", TimeHelper.ConverIntToString(plist.Duration), plist.NumberOfTracks, plist.NumberOfVideos); Cover = AIGS.Common.Convert.ConverByteArrayToBitmapImage(plist.CoverData); foreach (Track item in plist.Tracks) { DLItemList.Add(new DownloadItem(DLItemList.Count + 1, item, null, album: null, plist: plist)); } foreach (Video item in plist.Videos) { DLItemList.Add(new DownloadItem(DLItemList.Count + 1, null, item, album: null, plist: plist)); } } PathHelper.Mkdirs(BasePath); }
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; }
/// <summary> /// Search thread /// </summary> /// <param name="data">ID</param> private void ThreadFunc_Search(object[] data) { ThreadResultNotify mothed = new ThreadResultNotify(SearchResult); //search album Album aAlbum = TidalTool.GetAlbum(data[0].ToString(), false, Enum.GetName(typeof(Quality), Para.Config.Quality)); this.Dispatcher.Invoke(mothed, "Album", aAlbum); return; }
public void Confirm() { Config.ThreadNum((ThreadNum + 1).ToString()); Config.SearchNum(((SearchNum + 1) * 10).ToString()); Config.OnlyM4a(OnlyM4a.ToString()); Config.ToChinese(ToChinese.ToString()); Config.AddHyphen(AddHyphen.ToString()); Config.Quality(QualityList[SelectQualityIndex].ToLower()); Config.Resolution(ResolutionList[SelectResolutionIndex]); Config.OutputDir(OutputDir); TidalTool.SetSearchMaxNum(int.Parse(Config.SearchNum())); ThreadTool.SetThreadNum(ThreadNum + 1); RequestClose(); }
private void AddAlbum(Album album) { string CoverPath = TidalTool.getAlbumCoverPath(Config.OutputDir(), album); FileHelper.Write(album.CoverData, true, CoverPath); foreach (Track item in album.Tracks) { DLItemList.Add(new DownloadItem(DLItemList.Count + 1, item, null, album: album)); } foreach (Video item in album.Videos) { DLItemList.Add(new DownloadItem(DLItemList.Count + 1, null, item, album: album)); } }
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 async void Search() { if (InSearch) { return; } if (SearchStr.IsBlank()) { Errlabel = "Search String is Empty!"; return; } //Search InSearch = true; eObjectType SearchType = eObjectType.None; object SearchObj = await Task.Run(() => { return(TidalTool.tryGet(SearchStr, out SearchType)); }); InSearch = false; if (SearchType == eObjectType.None) { Errlabel = "Search Err!"; return; } if (SearchType == Tidal.eObjectType.SEARCH) { VMSearch.Load((Tidal.SearchResult)SearchObj); Manager.ShowDialog(VMSearch); SearchType = VMSearch.ResultType; SearchObj = VMSearch.ResultObject; if (SearchType == eObjectType.None) { return; } } SearchObj = VMInfo.Load(SearchObj); Manager.ShowDialog(VMInfo); if (VMInfo.Result) { MainListItemViewModel newNode = new MainListItemViewModel(SearchObj, ItemList); ItemList.Add(newNode); newNode.StartWork(); } }
public async void Login() { if (ShowKeyView == Visibility.Visible) { return; } Errlabel = ""; if (Username.IsBlank() || Password.IsBlank()) { Errlabel = "Username or password is err!"; return; } BtnLoginEnable = false; //Proxy TidalTool.PROXY = ProxyEnable ? new HttpHelper.ProxyInfo(ProxyHost, ProxyPort, ProxyUser, ProxyPwd) : null; Config.ProxyEnable(ProxyEnable.ToString()); Config.ProxyHost(ProxyHost); Config.ProxyPort(ProxyPort.ToString()); Config.ProxyUser(ProxyUser); Config.ProxyPwd(ProxyPwd); //Login bool bRet = await Task.Run(() => { return(TidalTool.login(Username, Password)); }); if (!bRet) { Errlabel = "Login Err! " + TidalTool.loginErrlabel; BtnLoginEnable = true; return; } if (Remember) { Config.Username(Username); Config.Password(Password); } BtnLoginEnable = true; VMMain.VMLogin = this; Manager.ShowWindow(VMMain); RequestClose(); return; }
public VideoTask(Video data, int index, TELL_PARENT_OVER tellparent, Album album = null, Playlist playlist = null) { Index = index; Title = data.Title; Own = data.Artist.Name; Progress = new ProgressHelper(false); TellParentOver = tellparent; TidalVideo = data; TidalAlbum = album; TidalPlaylist = playlist; Resolution = TidalTool.getResolution(Config.Resolution()); AddHyphen = Config.AddHyphen(); ArtistBeforeTitle = Config.ArtistBeforeTitle(); AddYear = Config.AddYear(); OutputDir = Config.OutputDir(); Start(); }
public void ReadLoadSubList(MainItem main) { if (main.Type == "ALBUM") { ObservableCollection <Track> pList = TidalTool.GetAlbumTracks(((Album)main.data).ID.ToString(), true, eQuality: Para.Config.Quality); for (int i = 0; i < pList.Count; i++) { if (pList[i].StreamUrl == null) { continue; } ((Track)main.SubList[i].data).StreamUrl = pList[i].StreamUrl; main.SubList[i].DownloadUrl = pList[i].StreamUrl; main.SubList[i].TotalSize = pList[i].StreamUrl.FileSize; main.TotalSize += pList[i].StreamUrl.FileSize; } } }
public void RefreshSetting() { OutputDir = Config.OutputDir(); OnlyM4a = Config.OnlyM4a(); AddExplicitTag = Config.AddExplicitTag(); IncludeEPSingle = Config.IncludeEP(); AddHyphen = Config.AddHyphen(); SaveCovers = Config.SaveCovers(); ToChinese = Config.ToChinese(); MaxFileName = CheckMaxName(Config.MaxFileName()); MaxDirName = CheckMaxName(Config.MaxDirName()); CheckExist = Config.CheckExist(); ArtistBeforeTitle = Config.ArtistBeforeTitle(); AddYearIndex = Config.AddYear(); ThreadNum = AIGS.Common.Convert.ConverStringToInt(Config.ThreadNum()) - 1; SearchNum = AIGS.Common.Convert.ConverStringToInt(Config.SearchNum()) / 10 - 1; QualityList = TidalTool.getQualityList(); ResolutionList = TidalTool.getResolutionList(); SelectQualityIndex = QualityList.IndexOf(Config.Quality().ToUpper()); SelectResolutionIndex = ResolutionList.IndexOf(Config.Resolution().ToUpper()); UseTrackNumber = Config.UseTrackNumber(); AddAlbumIDBeforeFolder = Config.AddAlbumIDBeforeFolder(); if (SelectQualityIndex < 0) { SelectQualityIndex = 0; } if (SelectResolutionIndex < 0) { SelectResolutionIndex = 0; } if (ThreadNum < 0) { ThreadNum = 0; } if (SearchNum < 0 || SearchNum > 5) { SearchNum = 0; } }
public TrackTask(Track data, int index, TELL_PARENT_OVER tellparent, Album album = null, Playlist playlist = null) { Index = index; Title = data.Title; Own = album == null ? null : album.Title; Progress = new ProgressHelper(false); TellParentOver = tellparent; TidalTrack = data; TidalAlbum = album; TidalPlaylist = playlist; Quality = TidalTool.getQuality(Config.Quality()); OnlyM4a = Config.OnlyM4a(); AddHyphen = Config.AddHyphen(); UseTrackNumber = Config.UseTrackNumber(); CheckExist = Config.CheckExist(); ArtistBeforeTitle = Config.ArtistBeforeTitle(); AddExplict = Config.AddExplicitTag(); AddYear = Config.AddYear(); OutputDir = Config.OutputDir(); Start(); }
public MainViewModel(IWindowManager manager, SettingViewModel setting, AboutViewModel about, InfoViewModel albuminfo, SearchViewModel search, DllistViewModel dllist) { Manager = manager; VMSetting = setting; VMAbout = about; VMInfo = albuminfo; VMSearch = search; VMDllist = dllist; ThreadTool.SetThreadNum(int.Parse(Config.ThreadNum())); UpdateThread = new Thread(ThreadUpdateFunc); UpdateThread.IsBackground = true; UpdateThread.Start(); QualityList = TidalTool.getQualityList(); SelectQualityIndex = QualityList.IndexOf(Config.Quality().ToUpper()); if (SelectQualityIndex < 0) { SelectQualityIndex = 0; } ResolutionList = TidalTool.getResolutionList(); SelectResolutionIndex = ResolutionList.IndexOf(Config.Resolution().ToUpper()); if (SelectResolutionIndex < 0) { SelectResolutionIndex = 0; } TidalTool.SetSearchMaxNum(int.Parse(Config.SearchNum())); //test //VMDllist.Convert(); //return; }
public SettingViewModel() { OutputDir = Config.OutputDir(); OnlyM4a = Config.OnlyM4a(); ThreadNum = AIGS.Common.Convert.ConverStringToInt(Config.ThreadNum()) - 1; QualityList = TidalTool.getQualityList(); ResolutionList = TidalTool.getResolutionList(); SelectQualityIndex = QualityList.IndexOf(Config.Quality().ToUpper()); SelectResolutionIndex = ResolutionList.IndexOf(Config.Resolution().ToUpper()); if (SelectQualityIndex < 0) { SelectQualityIndex = 0; } if (SelectResolutionIndex < 0) { SelectResolutionIndex = 0; } if (ThreadNum < 0) { ThreadNum = 0; } }
public void Confim() { Config.ThreadNum(ThreadNum.ToString()); Config.SearchNum(SearchNum.ToString()); Config.OnlyM4a(OnlyM4a.ToString()); Config.AddExplicitTag(AddExplicitTag.ToString()); Config.SaveCovers(SaveCovers.ToString()); Config.IncludeEP(IncludeEPSingle.ToString()); Config.CheckExist(CheckExist.ToString()); Config.ArtistBeforeTitle(ArtistBeforeTitle.ToString()); Config.AddHyphen(AddHyphen.ToString()); Config.AddYear(AddYearIndex); Config.OutputDir(OutputDir); Config.UseTrackNumber(UseTrackNumber.ToString()); Config.MaxFileName(MaxFileName.ToString()); Config.MaxDirName(MaxDirName.ToString()); Config.AddAlbumIDBeforeFolder(AddAlbumIDBeforeFolder.ToString()); Config.ThemeIndex(ThemeIndex.ToString()); TidalTool.SetSearchMaxNum(int.Parse(Config.SearchNum())); ThreadTool.SetThreadNum(ThreadNum); ChangeTheme(ThemeIndex); if (AccessToken.IsNotBlank()) { if (TidalTool.loginByAccesstoken(AccessToken)) { Config.Accesstoken(AccessToken); } else { Growl.Warning("Accesstoken is not valid!", "SettingsMsg"); return; } } Growl.Success("Refresh settings success!", "SettingsMsg"); }
public DownloadItem(int index, Track track = null, Video video = null, Album album = null) { TidalAlbum = album; TidalVideo = video; TidalTrack = track; Quality = TidalTool.getQuality(Config.Quality()); Resolution = TidalTool.getResolution(Config.Resolution()); OutputDir = Config.OutputDir(); Index = index; Progress = new ProgressHelper(); OnlyM4a = Config.OnlyM4a(); Own = album == null?null : album.Title; if (TidalTrack != null) { Title = track.Title; sType = "MusicCircle"; } else { Title = video.Title; sType = "PlayCircle"; } }
public object Load(object data) { AllCheck = true; Data = data; FlagDetail = ""; Modes = ""; if (data.GetType() == typeof(Playlist)) { Playlist plist = (Playlist)data; Header = "PLAYLISTINFO"; Title = plist.Title; //Intro = string.Format("by {0}-{1} Tracks-{2} Videos-{3}", plist.Created, TimeHelper.ConverIntToString(plist.Duration), plist.NumberOfTracks, plist.NumberOfVideos); Intro = string.Format("{0} Tracks-{1} Videos-{2}", TimeHelper.ConverIntToString(plist.Duration), plist.NumberOfTracks, plist.NumberOfVideos); Cover = AIGS.Common.Convert.ConverByteArrayToBitmapImage(plist.CoverData); ReleaseDate = ""; ItemList = new ObservableCollection <InfoItem>(); if (plist.Tracks != null) { foreach (Track item in plist.Tracks) { ItemList.Add(new InfoItem(plist.Tracks.IndexOf(item) + 1, item.Title, TimeHelper.ConverIntToString(item.Duration), item.Album.Title, item, flag: TidalTool.getFlag(item))); } } if (plist.Videos != null) { foreach (Video item in plist.Videos) { ItemList.Add(new InfoItem(plist.Tracks.Count + plist.Videos.IndexOf(item) + 1, item.Title, TimeHelper.ConverIntToString(item.Duration), item.Title, item, "VIDEO")); } } } else if (data.GetType() == typeof(Artist)) { Artist artist = (Artist)data; Header = "ARTISTINFO"; Title = artist.Name; Intro = string.Format("by {0} Albums-{1}", artist.Name, artist.Albums.Count); Cover = AIGS.Common.Convert.ConverByteArrayToBitmapImage(artist.CoverData); ReleaseDate = ""; ItemList = new ObservableCollection <InfoItem>(); if (artist.Albums != null) { foreach (Album item in artist.Albums) { ItemList.Add(new InfoItem(artist.Albums.IndexOf(item) + 1, item.Title, TimeHelper.ConverIntToString(item.Duration), item.Title, item, "ALBUM", flag: TidalTool.getFlag(item))); } } } else if (data.GetType() == typeof(Album)) { Album album = (Album)data; Header = "ALBUMINFO"; Title = album.Title; Intro = string.Format("by {0}-{1} Tracks-{2} Videos-{3}", album.Artist.Name, TimeHelper.ConverIntToString(album.Duration), album.NumberOfTracks, album.NumberOfVideos); Cover = AIGS.Common.Convert.ConverByteArrayToBitmapImage(album.CoverData); ReleaseDate = "Release date " + album.ReleaseDate; ItemList = new ObservableCollection <InfoItem>(); if (album.Tracks != null) { foreach (Track item in album.Tracks) { ItemList.Add(new InfoItem(item.TrackNumber, item.Title, TimeHelper.ConverIntToString(item.Duration), item.Album.Title, item, flag: TidalTool.getFlag(item))); } } if (album.Videos != null) { foreach (Video item in album.Videos) { ItemList.Add(new InfoItem(item.TrackNumber, item.Title, TimeHelper.ConverIntToString(item.Duration), item.Album.Title, item, "VIDEO")); } } //FlagDetail if (album.AudioQuality == "HI_RES") { FlagDetail += "Master "; } if (album.Explicit) { FlagDetail += "Explicit"; } //Modes if (album.AudioModes != null && album.AudioModes.Count() > 0) { foreach (var item in album.AudioModes) { Modes += item + " "; } } } else if (data.GetType() == typeof(Video)) { Video video = (Video)data; Header = "VIDEOINFO"; Title = video.Title; Cover = AIGS.Common.Convert.ConverByteArrayToBitmapImage(video.CoverData); Intro = string.Format("by {0}-{1}", video.Artist.Name, TimeHelper.ConverIntToString(video.Duration)); ReleaseDate = "Release date " + video.ReleaseDate; ItemList = new ObservableCollection <InfoItem>(); ItemList.Add(new InfoItem(0, video.Title, TimeHelper.ConverIntToString(video.Duration), video.Album == null ? "" : video.Album.Title, data, "VIDEO")); } return(data); }
public void Logout() { TidalTool.logout(); Manager.ShowWindow(VMLogin); WindowClose(); }
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; } //Get path FilePath = TidalTool.getTrackPath(OutputDir, TidalAlbum, TidalTrack, TidalStream.Url, AddHyphen, TidalPlaylist, artistBeforeTitle: ArtistBeforeTitle); //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 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); 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) { string sNewName; if (!TidalTool.ConvertMp4ToM4a(FilePath, out sNewName)) { Errlabel = "Convert mp4 to m4a failed!"; 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), pContributors); if (sLabel.IsNotBlank()) { Errlabel = "Set metadata failed!"; 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; }