Skip to content

Commit

Permalink
upload new version
Browse files Browse the repository at this point in the history
  • Loading branch information
yaronzz committed Nov 2, 2020
1 parent 66e5332 commit 10d4575
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 13 deletions.
6 changes: 5 additions & 1 deletion TIDALDL-UI-PRO/Else/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,15 @@ public class Settings : Stylet.Screen
public ePositionYear AddYear { get; set; } = ePositionYear.None;

[JsonProperty("AlbumFolderFormat")]
public string AlbumFolderFormat { get; set; } = "{Flag} {AlbumTitle} [{AlbumID}] [{AlbumYear}]";

public string AlbumFolderFormat { get; set; } = "{ArtistName}/{Flag} {AlbumTitle} [{AlbumID}] [{AlbumYear}]";

[JsonProperty("TrackFileFormat")]
public string TrackFileFormat { get; set; } = "{TrackNumber} - {ArtistName} - {TrackTitle}{ExplicitFlag}";

[JsonProperty("VideoFileFormat")]
public string VideoFileFormat { get; set; } = "{ArtistName}/{TrackNumber} - {VideoTitle}{ExplicitFlag}";


public static void Change(Settings newItem, Settings oldItem = null)
{
Expand Down
61 changes: 54 additions & 7 deletions TIDALDL-UI-PRO/Else/Tools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,22 +55,26 @@ public static string GetArtistPath(Artist artist, Settings settings)
return basepath;
}

//[{Flag}] [{AlbumID}] [{AlbumYear}] {AlbumTitle}
//{ArtistName}/{Flag} [{AlbumID}] [{AlbumYear}] {AlbumTitle}
public static string GetAlbumPath(Album album, Settings settings)
{
// outputdir/Album/artist/
string basepath = $"{settings.OutputDir}/Album/{FormatPath(album.Artists[0].Name, settings)}";
// outputdir/Album/
string basepath = $"{settings.OutputDir}/Album/";
// string basepath = $"{settings.OutputDir}/Album/{FormatPath(album.Artists[0].Name, settings)}";

// album folder pre: [ME][ID]
string flag = Client.GetFlag(album, eType.ALBUM, true, "");
if (settings.AudioQuality != eAudioQuality.Master)
flag = flag.Replace("M", "");
if (flag.IsNotBlank())
flag = $"[{flag}]";

string artist = FormatPath(album.Artists[0].Name, settings);

string name = settings.AlbumFolderFormat;
if (name.IsBlank())
name = "[{Flag}] [{AlbumID}] [{AlbumYear}] {AlbumTitle}";
name = "{ArtistName}/{Flag} [{AlbumID}] [{AlbumYear}] {AlbumTitle}";
name = name.Replace("{ArtistName}", artist);
name = name.Replace("{AlbumID}", album.ID);
name = name.Replace("{AlbumYear}", album.ReleaseDate.Substring(0, 4));
name = name.Replace("{AlbumTitle}", FormatPath(album.Title, settings));
Expand Down Expand Up @@ -127,13 +131,13 @@ public static string GetTrackPath(Settings settings, Track track, StreamUrl stre

//get explicit
string sexplicit = "";
if (settings.AddExplicitTag && track.Explicit)
if (track.Explicit)
sexplicit = "(Explicit)";

//get version
string version = "";
if (track.Version.IsNotBlank())
version = "(" + track.Version + ")";
version = " (" + track.Version + ")";

//get title
string title = FormatPath(track.Title + version, settings, false);
Expand All @@ -159,6 +163,10 @@ public static string GetTrackPath(Settings settings, Track track, StreamUrl stre
name = name.Replace("{ArtistName}", artist);
name = name.Replace("{TrackTitle}", title);
name = name.Replace("{ExplicitFlag}", sexplicit);

name = name.Replace("{AlbumID}", album.ID);
name = name.Replace("{AlbumYear}", album.ReleaseDate.Substring(0, 4));
name = name.Replace("{AlbumTitle}", FormatPath(album.Title, settings));
return $"{basepath}{name}{extension}";
}

Expand Down Expand Up @@ -215,8 +223,47 @@ public static string GetTrackPath2(Settings settings, Track track, StreamUrl str
return path;
}

// number - artist - title(Explicit).mp4
// {ArtistName}/{TrackNumber} - {VideoTitle}.mp4
public static string GetVideoPath(Settings settings, Video video, Album album, Playlist playlist = null, string ext = ".mp4")
{
//get number
string number = video.TrackNumber.ToString().PadLeft(2, '0');
if (playlist != null)
number = (playlist.Videos.IndexOf(video) + 1).ToString().PadLeft(2, '0');

//get artist
string artist = FormatPath(video.Artists[0].Name, settings, false);

//get explicit
string sexplicit = "";
if (video.Explicit)
sexplicit = "(Explicit)";

//get title
string title = FormatPath(video.Title, settings, false);

//base path
string basepath = null;
if (album != null)
basepath = GetAlbumPath(album, settings);
else if (playlist != null)
basepath = GetPlaylistPath(playlist, settings);
else
basepath = $"{settings.OutputDir}/Video/";

string name = settings.VideoFileFormat;
if (name.IsBlank())
name = "{ArtistName}/{TrackNumber} - {VideoTitle}";
name = name.Replace("{TrackNumber}", number);
name = name.Replace("{ArtistName}", artist);
name = name.Replace("{VideoTitle}", title);
name = name.Replace("{ExplicitFlag}", sexplicit);

return $"{basepath}{name}{ext}";
}

// number - artist - title(Explicit).mp4
public static string GetVideoPath2(Settings settings, Video video, Album album, Playlist playlist = null, string ext = ".mp4")
{
//hyphen
string hyphen = " ";
Expand Down
1 change: 1 addition & 0 deletions TIDALDL-UI-PRO/Else/TrackTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ public void Download()
}
}
Progress.Errmsg = "Download failed!";
System.IO.File.Delete(path);

ERR_RETURN:
if (Progress.GetStatus() == ProgressHelper.STATUS.CANCLE)
Expand Down
2 changes: 1 addition & 1 deletion TIDALDL-UI-PRO/Pages/SearchViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ public Detail(Album album)
ReleaseDate = $"Release date {album.ReleaseDate}";
Flag = album.Flag;

for (int i = 0; i < album.NumberOfTracks; i++)
for (int i = 0; i < album.NumberOfTracks && i < album.Tracks.Count; i++)
{
Items.Add(new Item()
{
Expand Down
6 changes: 5 additions & 1 deletion TIDALDL-UI-PRO/Pages/SettingsView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@

<RowDefinition Height="45"/>
<RowDefinition Height="45"/>
<RowDefinition Height="15"/>
<RowDefinition Height="45"/>

<RowDefinition Height="35"/>
<RowDefinition Height="35"/>
<RowDefinition Height="15"/>
Expand Down Expand Up @@ -82,6 +83,9 @@
<TextBlock Grid.Row="5" Text="TrackFileFormat:" VerticalAlignment="Center" Padding="20,0" HorizontalAlignment="Right" />
<TextBox Grid.Row="5" Grid.Column="1" Text="{Binding Settings.TrackFileFormat}" hc:InfoElement.Placeholder="eg: {TrackNumber} - {ArtistName} - {TrackTitle}{ExplicitFlag} -->> 01 - Back Number - Happy End(Explicit)" Margin="0,6,10,6"/>

<TextBlock Grid.Row="6" Text="VideoFileFormat:" VerticalAlignment="Center" Padding="20,0" HorizontalAlignment="Right" />
<TextBox Grid.Row="6" Grid.Column="1" Text="{Binding Settings.VideoFileFormat}" hc:InfoElement.Placeholder="eg: {ArtistName}/{TrackNumber} - {VideoTitle} -->> Back Number\\01 - Happy End" Margin="0,6,10,6"/>

<TextBlock Grid.Row="7" Text="Choose:" VerticalAlignment="Center" Padding="20,0" HorizontalAlignment="Right" />
<!--<CheckBox Grid.Row="5" Grid.Column="1" IsChecked="{Binding Settings.ArtistBeforeTitle}" Content="Add artist-name before title, like 'adele - hello.flac'" HorizontalAlignment="Left"/>-->
<!--<CheckBox Grid.Row="6" Grid.Column="1" IsChecked="{Binding Settings.AddAlbumIDBeforeFolder}" Content="Add album-id befor album-folder, like '[123] Only one'" HorizontalAlignment="Left"/>-->
Expand Down
4 changes: 2 additions & 2 deletions TIDALDL-UI-PRO/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,5 @@
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.2.0.5")]
[assembly: AssemblyFileVersion("1.2.0.5")]
[assembly: AssemblyVersion("1.2.0.6")]
[assembly: AssemblyFileVersion("1.2.0.6")]
6 changes: 5 additions & 1 deletion TIDALDL-UI-PRO/UPDATE_LOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
- [ ] Auto update
- [ ] Multi-language

- [x] Fix: replace track "title(version)" illegal characters
#### v1.2.0.6
- [x] Fix: replace track "title (version)" illegal characters
- [x] Default AlbumFolderFormat: {ArtistName}/{Flag} [{AlbumID}] [{AlbumYear}] {AlbumTitle}
- [x] Settings: Video file format [#48](https://github.com/yaronzz/Tidal-Media-Downloader-PRO/issues/48)
- [x] Delete file if download err. [#40](https://github.com/yaronzz/Tidal-Media-Downloader-PRO/issues/40)

#### v1.2.0.5
- [x] Fix: download video(get stream) [#30](https://github.com/yaronzz/Tidal-Media-Downloader-PRO/issues/30)
Expand Down

0 comments on commit 10d4575

Please sign in to comment.