Skip to content

Commit

Permalink
Add optional URL metadata Tag (resolves #41)
Browse files Browse the repository at this point in the history
- Add option to write album store URL to audiofile metadata
  • Loading branch information
DJDoubleD committed Aug 27, 2023
1 parent 50ff9ce commit 08dc6e6
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 1 deletion.
3 changes: 3 additions & 0 deletions QobuzDownloaderX/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,9 @@
<setting name="releaseDateTag" serializeAs="String">
<value>True</value>
</setting>
<setting name="urlTag" serializeAs="String">
<value>True</value>
</setting>
</QobuzDownloaderX.Properties.Settings>
</userSettings>
</configuration>
3 changes: 3 additions & 0 deletions QobuzDownloaderX/Models/Download/DownloadItemInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public class DownloadItemInfo
public string FrontCoverImgTagUrl { get; set; }
public string FrontCoverImgBoxUrl { get; set; }
public string MediaType { get; set; }
public string Url { get; set; }

// Info / Tagging numbers
public int DiscNumber { get; set; }
Expand Down Expand Up @@ -74,6 +75,7 @@ private void ClearAlbumTaggingInfo()
ReleaseDate = null;
Upc = null;
MediaType = null;
Url = null;

// Clear tag numbers
TrackTotal = 0;
Expand Down Expand Up @@ -156,6 +158,7 @@ public void SetAlbumTaggingInfo(Album qobuzAlbum)
ReleaseDate = StringTools.FormatDateTimeOffset(qobuzAlbum.ReleaseDateStream);
Upc = qobuzAlbum.Upc;
MediaType = qobuzAlbum.ReleaseType;
Url = qobuzAlbum.Url;

// Grab tag ints
TrackTotal = qobuzAlbum.TracksCount.GetValueOrDefault();
Expand Down
12 changes: 12 additions & 0 deletions QobuzDownloaderX/Properties/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions QobuzDownloaderX/Properties/Settings.settings
Original file line number Diff line number Diff line change
Expand Up @@ -137,5 +137,8 @@
<Setting Name="releaseDateTag" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">True</Value>
</Setting>
<Setting Name="urlTag" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">True</Value>
</Setting>
</Settings>
</SettingsFile>
1 change: 1 addition & 0 deletions QobuzDownloaderX/Shared/TaggingOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ internal class TaggingOptions
public bool WriteLabelTag { get; set; }
public bool WriteInvolvedPeopleTag { get; set; }
public bool MergePerformers { get; set; }
public bool WriteUrlTag { get; set; }
public string CommentTag { get; set; }
public string ArtSize { get; set; }
public string PrimaryListSeparator { get; set; }
Expand Down
6 changes: 6 additions & 0 deletions QobuzDownloaderX/Shared/Tools/AudioFileTagger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,9 @@ public static void AddMetaDataTags(DownloadItemInfo fileInfo, string tagFilePath
// Release Type tag
if (fileInfo.MediaType != null && Globals.TaggingOptions.WriteMediaTypeTag) { customId3v2.SetTextFrame("TMED", fileInfo.MediaType); }

// Album store URL tag
if (fileInfo.Url != null && Globals.TaggingOptions.WriteUrlTag) { customId3v2.SetTextFrame("WCOM", fileInfo.Url); }

// Save all selected tags to file
tfile.Save();

Expand Down Expand Up @@ -292,6 +295,9 @@ public static void AddMetaDataTags(DownloadItemInfo fileInfo, string tagFilePath
if (fileInfo.Advisory == true) { custom.SetField("ITUNESADVISORY", "1"); } else { custom.SetField("ITUNESADVISORY", "0"); }
}

// Album store URL tag
if (fileInfo.Url != null && Globals.TaggingOptions.WriteUrlTag) { custom.SetField("URL", fileInfo.Url); }

// Save all selected tags to file
tfile.Save();

Expand Down
18 changes: 18 additions & 0 deletions QobuzDownloaderX/View/MainForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 10 additions & 1 deletion QobuzDownloaderX/View/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ private void MainForm_Load(object sender, EventArgs e)
WriteUpcTag = Settings.Default.upcTag,
WriteReleaseYearTag = Settings.Default.yearTag,
WriteReleaseDateTag = Settings.Default.releaseDateTag,
WriteCoverImageTag = Settings.Default.imageTag
WriteCoverImageTag = Settings.Default.imageTag,
WriteUrlTag = Settings.Default.urlTag
};

// Set saved settings to correct places.
Expand Down Expand Up @@ -153,6 +154,7 @@ private void MainForm_Load(object sender, EventArgs e)
releasYearCheckbox.Checked = Settings.Default.yearTag;
releaseDateCheckbox.Checked = Settings.Default.releaseDateTag;
imageCheckbox.Checked = Settings.Default.imageTag;
urlCheckBox.Checked = Settings.Default.urlTag;
mp3Checkbox.Checked = Settings.Default.quality1;
flacLowCheckbox.Checked = Settings.Default.quality2;
flacMidCheckbox.Checked = Settings.Default.quality3;
Expand Down Expand Up @@ -640,6 +642,13 @@ private void ListEndSeparatorTextbox_TextChanged(object sender, EventArgs e)
}
}

private void UrlCheckbox_CheckedChanged(object sender, EventArgs e)
{
Settings.Default.urlTag = urlCheckBox.Checked;
Settings.Default.Save();
Globals.TaggingOptions.WriteUrlTag = urlCheckBox.Checked;
}

private void flacHighCheckbox_CheckedChanged(object sender, EventArgs e)
{
Settings.Default.quality4 = flacHighCheckbox.Checked;
Expand Down

0 comments on commit 08dc6e6

Please sign in to comment.