diff --git a/TIDALDL-UI/TIDALDL-UI/Else/DownloadItem.cs b/TIDALDL-UI/TIDALDL-UI/Else/DownloadItem.cs index fee9e2d5..148e46a4 100644 --- a/TIDALDL-UI/TIDALDL-UI/Else/DownloadItem.cs +++ b/TIDALDL-UI/TIDALDL-UI/Else/DownloadItem.cs @@ -9,6 +9,7 @@ using Stylet; using TagLib; using System.IO; +using System.Collections.ObjectModel; namespace TIDALDL_UI.Else { @@ -158,14 +159,20 @@ public void DownloadVideo() #region DownloadTrack public void DownloadTrack() { + string Errlabel = ""; + //GetStream Progress.StatusMsg = "GetStream..."; - string Errlabel = ""; 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); + //Get contributors + ObservableCollection<Contributor> pContributors = TidalTool.getTrackContributors(TidalTrack.ID.ToString(), out Errlabel); + //Download Progress.StatusMsg = "Start..."; for (int i = 0; i < 100 && Progress.GetStatus() != ProgressHelper.STATUS.CANCLE; i++) @@ -197,7 +204,7 @@ public void DownloadTrack() string sErrcode = null; TidalAlbum = TidalTool.getAlbum(TidalTrack.Album.ID.ToString(), out sErrcode); } - string sLabel = TidalTool.SetMetaData(FilePath, TidalAlbum, TidalTrack, TidalTool.getAlbumCoverPath(OutputDir, TidalAlbum)); + string sLabel = TidalTool.SetMetaData(FilePath, TidalAlbum, TidalTrack, TidalTool.getAlbumCoverPath(OutputDir, TidalAlbum), pContributors); if (sLabel.IsNotBlank()) { Errlabel = "Set metadata failed!"; diff --git a/TIDALDL-UI/TIDALDL-UI/Pages/MainView.xaml b/TIDALDL-UI/TIDALDL-UI/Pages/MainView.xaml index c385f4c7..e328220c 100644 --- a/TIDALDL-UI/TIDALDL-UI/Pages/MainView.xaml +++ b/TIDALDL-UI/TIDALDL-UI/Pages/MainView.xaml @@ -47,7 +47,7 @@ <StackPanel DockPanel.Dock="Top" Orientation="Horizontal" materialDesign:RippleAssist.IsCentered="True"> <materialDesign:PackIcon Kind="MusicCircleOutline" Height="Auto" Width="30" HorizontalAlignment="Left" Padding="0,4" VerticalAlignment="Stretch"/> <TextBlock Text="TIDAL-GUI" FontWeight="Bold" VerticalAlignment="Center" Margin="0 0 0 0" FontSize="18" Padding="4,0,0,0"/> - <materialDesign:ColorZone IsEnabled="{Binding Path=InSearch, Converter={StaticResource ConverterUnbool}}" Mode="Standard" Padding="4 0 4 0" Panel.ZIndex="1" Margin="16 0 0 0" materialDesign:ShadowAssist.ShadowDepth="Depth1" Width="488"> + <materialDesign:ColorZone IsEnabled="{Binding Path=InSearch, Converter={StaticResource ConverterUnbool}}" Mode="Standard" Padding="4 0 4 0" Panel.ZIndex="1" Margin="16 0 0 0" materialDesign:ShadowAssist.ShadowDepth="Depth1" Width="673"> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="26" /> @@ -65,10 +65,10 @@ BorderThickness="0" MinWidth="200" VerticalAlignment="Center" Grid.ColumnSpan="2" /> - <Button Grid.Column="2" Command="{s:Action Search}" s:View.ActionTarget="{Binding}" Style="{DynamicResource MaterialDesignToolButton}" IsDefault="True" Margin="394,2,0,2" HorizontalAlignment="Left" Width="29"> + <Button Grid.Column="2" Command="{s:Action Search}" s:View.ActionTarget="{Binding}" Style="{DynamicResource MaterialDesignToolButton}" IsDefault="True" Margin="0,2,31,2" HorizontalAlignment="Right" Width="29"> <materialDesign:PackIcon Kind="Magnify" Opacity=".56" /> </Button> - <Button Grid.Column="2" Command="{s:Action OpenDllist}" s:View.ActionTarget="{Binding}" Style="{DynamicResource MaterialDesignToolButton}" Margin="423,2,0,2" HorizontalAlignment="Left" Width="31"> + <Button Grid.Column="2" Command="{s:Action OpenDllist}" s:View.ActionTarget="{Binding}" Style="{DynamicResource MaterialDesignToolButton}" Margin="0,2" HorizontalAlignment="Right" Width="31"> <materialDesign:PackIcon Kind="FileDocumentBoxOutline" Opacity=".56" /> </Button> </Grid> diff --git a/TIDALDL-UI/TIDALDL-UI/Pages/SettingView.xaml b/TIDALDL-UI/TIDALDL-UI/Pages/SettingView.xaml index 878207dd..49bdc43a 100644 --- a/TIDALDL-UI/TIDALDL-UI/Pages/SettingView.xaml +++ b/TIDALDL-UI/TIDALDL-UI/Pages/SettingView.xaml @@ -40,7 +40,7 @@ </Border> <Grid Grid.Column="1" Visibility="{Binding CheckCommon, Converter={x:Static s:BoolToVisibilityConverter.Instance}}"> - <Label Content="OutputDir" FontSize="15" VerticalAlignment="Top" HorizontalContentAlignment="Left" Margin="10,33,312,0" /> + <Label Content="OutputDir" FontSize="15" VerticalAlignment="Top" HorizontalContentAlignment="Right" Margin="10,33,312,0" /> <Button Style="{StaticResource MaterialDesignFlatButton}" Name="m_CPath" ToolTip="Choose Path" @@ -50,7 +50,7 @@ Margin="107,32,22,0" HorizontalContentAlignment="Left" VerticalAlignment="Top" Height="30" Padding="0,4,16,4" BorderThickness="0,0,0,1" BorderBrush="#89000000"/> - <Label Content="ThreadNum" FontSize="15" VerticalAlignment="Top" HorizontalContentAlignment="Left" Margin="10,67,307,0" Height="30" /> + <Label Content="ThreadNum" FontSize="15" VerticalAlignment="Top" HorizontalContentAlignment="Right" Margin="10,67,307,0" Height="30" /> <ComboBox SelectedIndex="{Binding ThreadNum, UpdateSourceTrigger=PropertyChanged}" Margin="107,67,22,168"> <ComboBoxItem>1</ComboBoxItem> <ComboBoxItem>2</ComboBoxItem> @@ -61,21 +61,21 @@ </Grid> <Grid Grid.Column="1" Visibility="{Binding CheckTrack, Converter={x:Static s:BoolToVisibilityConverter.Instance}}"> - <Label Content="Quality" FontSize="15" VerticalAlignment="Top" HorizontalContentAlignment="Left" Margin="10,33,312,0" /> + <Label Content="Quality" FontSize="15" VerticalAlignment="Top" HorizontalContentAlignment="Right" Margin="10,33,312,0" /> <ComboBox ItemsSource="{Binding QualityList}" SelectedIndex="{Binding SelectQualityIndex , UpdateSourceTrigger=PropertyChanged}" - Margin="107,32,22,0" VerticalAlignment="Top" Height="30"/> - <Label Content="OnlyM4a" FontSize="15" VerticalAlignment="Top" HorizontalContentAlignment="Left" Margin="10,67,312,0" Height="30" /> + Margin="107,32,87,0" VerticalAlignment="Top" Height="30" Padding="6,6,0,6"/> + <Label Content="OnlyM4a" FontSize="15" VerticalAlignment="Top" HorizontalContentAlignment="Right" Margin="10,67,312,0" Height="30" /> <ToggleButton Style="{StaticResource MaterialDesignSwitchToggleButton}" IsChecked="{Binding OnlyM4a, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Height="33" VerticalAlignment="Top" Margin="107,64,262,0"/> - <Label Content="AddHyphen" FontSize="15" VerticalAlignment="Top" HorizontalContentAlignment="Left" Margin="10,97,312,0" Height="30" /> + <Label Content="AddHyphen" FontSize="15" VerticalAlignment="Top" HorizontalContentAlignment="Right" Margin="0,97,312,0" Height="30" /> <ToggleButton Style="{StaticResource MaterialDesignSwitchToggleButton}" IsChecked="{Binding AddHyphen, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Height="33" VerticalAlignment="Top" Margin="107,97,262,0"/> </Grid> <Grid Grid.Column="1" Visibility="{Binding CheckVideo, Converter={x:Static s:BoolToVisibilityConverter.Instance}}"> - <Label Content="Resolution" FontSize="15" VerticalAlignment="Top" HorizontalContentAlignment="Left" Margin="10,33,312,0" /> + <Label Content="Resolution" FontSize="15" VerticalAlignment="Top" HorizontalContentAlignment="Right" Margin="10,33,312,0" /> <ComboBox ItemsSource="{Binding ResolutionList}" SelectedIndex="{Binding SelectResolutionIndex , UpdateSourceTrigger=PropertyChanged}" - Margin="107,32,22,0" VerticalAlignment="Top" Height="28"> + Margin="107,32,87,0" VerticalAlignment="Top" Height="30" Padding="6,6,0,6"> </ComboBox> </Grid> </Grid> diff --git a/TIDALDL-UI/TIDALDL-UI/Properties/AssemblyInfo.cs b/TIDALDL-UI/TIDALDL-UI/Properties/AssemblyInfo.cs index ff6651f6..72f74c43 100644 --- a/TIDALDL-UI/TIDALDL-UI/Properties/AssemblyInfo.cs +++ b/TIDALDL-UI/TIDALDL-UI/Properties/AssemblyInfo.cs @@ -51,5 +51,5 @@ // 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号 // 方法是按如下所示使用“*”: : // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.1.0.6")] -[assembly: AssemblyFileVersion("1.1.0.6")] +[assembly: AssemblyVersion("1.1.0.7")] +[assembly: AssemblyFileVersion("1.1.0.7")] diff --git a/TIDALDL-UI/TIDALDL-UI/Tidal/Enum.cs b/TIDALDL-UI/TIDALDL-UI/Tidal/Enum.cs index 24192326..db6d8930 100644 --- a/TIDALDL-UI/TIDALDL-UI/Tidal/Enum.cs +++ b/TIDALDL-UI/TIDALDL-UI/Tidal/Enum.cs @@ -33,4 +33,27 @@ public enum eResolution e720P = 720, e1080P = 1080 } + + public enum eContributorRole + { + PRODUCER, + COMPOSER, + LYRICIST, + ASSOCIATED_PERFORMER, + BACKGROUND_VOCAL, + BASS, + DRUMS, + GUITAR, + MASTERING_ENGINEER, + MIX_ENGINEER, + PERCUSSION, + SYNTHESIZER, + VOCAL, + PERFORMER, + REMIXER, + ENSEMBLE_ORCHESTRA, + CHOIR, + CONDUCTOR, + ELSE, + } } diff --git a/TIDALDL-UI/TIDALDL-UI/Tidal/Model.cs b/TIDALDL-UI/TIDALDL-UI/Tidal/Model.cs index edbd9ce5..26f480c6 100644 --- a/TIDALDL-UI/TIDALDL-UI/Tidal/Model.cs +++ b/TIDALDL-UI/TIDALDL-UI/Tidal/Model.cs @@ -108,6 +108,12 @@ public class Video public byte[] CoverData { get; set; } } + public class Contributor + { + public string Name { get; set; } + public string Role { get; set; } + } + public class Playlist { public string UUID { get; set; } diff --git a/TIDALDL-UI/TIDALDL-UI/Tidal/TidalTool.cs b/TIDALDL-UI/TIDALDL-UI/Tidal/TidalTool.cs index 974f76dc..f1bcd4fc 100644 --- a/TIDALDL-UI/TIDALDL-UI/Tidal/TidalTool.cs +++ b/TIDALDL-UI/TIDALDL-UI/Tidal/TidalTool.cs @@ -217,6 +217,12 @@ public static StreamUrl getStreamUrl(string ID, eSoundQuality eQuality, out stri StreamUrl oObj = get<StreamUrl>("tracks/" + ID + "/streamUrl", out Errmsg, new Dictionary<string, string>() { { "soundQuality", sQua } }, 3); return oObj; } + + public static ObservableCollection<Contributor> getTrackContributors(string ID, out string Errmsg) + { + ObservableCollection<Contributor> aObj = get<ObservableCollection<Contributor>>("tracks/" + ID + "/contributors", out Errmsg, null, 3, "items"); + return aObj; + } #endregion #region Video @@ -554,11 +560,24 @@ private static string[] GetArtistNames(ObservableCollection<Artist> Artists) { List<string> pArrayStr = new List<string>(); for(int i = 0; i < Artists.Count; i++) - pArrayStr.Add(Artists[i].Name); + pArrayStr.Add(Artists[i].Name); + return pArrayStr.ToArray(); + } + + private static string[] GetRoles(ObservableCollection<Contributor> pContributors, eContributorRole eRole) + { + string sName = AIGS.Common.Convert.ConverEnumToString((int)eRole, typeof(eContributorRole)); + + List<string> pArrayStr = new List<string>(); + for (int i = 0; i < pContributors.Count; i++) + { + if (pContributors[i].Role.ToUpper().Replace(' ', '_') == sName) + pArrayStr.Add(pContributors[i].Name); + } return pArrayStr.ToArray(); } - public static string SetMetaData(string filepath, Album TidalAlbum, Track TidalTrack, string CoverPath) + public static string SetMetaData(string filepath, Album TidalAlbum, Track TidalTrack, string CoverPath, ObservableCollection<Contributor> pContributors) { try { @@ -572,9 +591,13 @@ public static string SetMetaData(string filepath, Album TidalAlbum, Track TidalT tfile.Tag.Copyright = TidalTrack.Copyright; tfile.Tag.AlbumArtists = GetArtistNames(TidalAlbum.Artists); tfile.Tag.Performers = GetArtistNames(TidalTrack.Artists); + tfile.Tag.Composers = GetRoles(pContributors, eContributorRole.COMPOSER); + //ReleaseDate if (TidalAlbum.ReleaseDate.IsNotBlank()) tfile.Tag.Year = (uint)AIGS.Common.Convert.ConverStringToInt(TidalAlbum.ReleaseDate.Split("-")[0]); + + //Cover if (CoverPath.IsNotBlank()) { var pictures = new Picture[1]; @@ -584,6 +607,7 @@ public static string SetMetaData(string filepath, Album TidalAlbum, Track TidalT pictures[0] = new Picture(CoverPath); tfile.Tag.Pictures = pictures; } + tfile.Save(); return null; } @@ -719,15 +743,18 @@ private static bool parseLink(ref string insStr, ref eObjectType inType) return false; string sID = sArr[1]; - if (AIGS.Common.Convert.ConverStringToInt(sID, -1) == -1) - return false; - eObjectType sType = eObjectType.None; - if (sArr[0] == "album") sType = eObjectType.ALBUM; - if (sArr[0] == "track") sType = eObjectType.TRACK; - if (sArr[0] == "video") sType = eObjectType.VIDEO; - if (sArr[0] == "artist") sType = eObjectType.ARTIST; - if (sArr[0] == "playlist") sType = eObjectType.PLAYLIST; + if (AIGS.Common.Convert.ConverStringToInt(sID, -1) == -1) + { + if (sArr[0] == "playlist") sType = eObjectType.PLAYLIST; + } + else + { + if (sArr[0] == "album") sType = eObjectType.ALBUM; + if (sArr[0] == "track") sType = eObjectType.TRACK; + if (sArr[0] == "video") sType = eObjectType.VIDEO; + if (sArr[0] == "artist") sType = eObjectType.ARTIST; + } if (sType == eObjectType.None) return false; diff --git a/TIDALDL-UI/TIDALDL-UI/updateLog.md b/TIDALDL-UI/TIDALDL-UI/updateLog.md index 14c66612..9be24a3e 100644 --- a/TIDALDL-UI/TIDALDL-UI/updateLog.md +++ b/TIDALDL-UI/TIDALDL-UI/updateLog.md @@ -1,7 +1,7 @@ #### v1.1.0.7 -- Add proxy-setting on login-page +- support http-proxy(login-page) - Download playlist -- Use artist cover when no album cover +- Tag: add composer #### v1.1.0.6 - Fix bug of search