public override bool GetTrackPath(TrackInfo track, out string path) { path = FileNamePattern.CreateFromTrackInfo( "%artist%%path_sep%%album%%path_sep%%track_number%. %title%", track); return(true); }
private void OnChanged(object o, EventArgs args) { string display = FileNamePattern.CreateFromTrackInfo(FileNamePattern.CreateFolderFilePattern( folder.ActiveValue, file.ActiveValue), track); Markup = String.IsNullOrEmpty(display) ? String.Empty : String.Format("<small>{0}.ogg</small>", GLib.Markup.EscapeText(display)); }
public void CreateFromTrackInfo() { SampleTrackInfo track = new SampleTrackInfo(); string built = FileNamePattern.CreateFromTrackInfo( "%artist%:%album%:%title%:%track_number%:" + "%track_count%:%track_number_nz%:%track_count_nz%", track); Assert.AreEqual(String.Format("{0}:{1}:{2}:{3}:{4}:{5}:{6}", track.ArtistName, track.AlbumTitle, track.TrackTitle, ZeroPad(track.TrackNumber), ZeroPad(track.TrackCount), track.TrackNumber, track.TrackCount), built); }
private string GetTrackPath(TrackInfo track, string ext) { string file_path = null; if (track.HasAttribute(TrackMediaAttributes.Podcast)) { string album = FileNamePattern.Escape(track.DisplayAlbumTitle); string title = FileNamePattern.Escape(track.DisplayTrackTitle); file_path = System.IO.Path.Combine("Podcasts", album); file_path = System.IO.Path.Combine(file_path, title); } else if (track.HasAttribute(TrackMediaAttributes.VideoStream)) { string album = FileNamePattern.Escape(track.DisplayAlbumTitle); string title = FileNamePattern.Escape(track.DisplayTrackTitle); file_path = System.IO.Path.Combine(album, title); } else if (ms_device == null || !ms_device.GetTrackPath(track, out file_path)) { // If the folder_depth property exists, we have to put the files in a hiearchy of // the exact given depth (not including the mount point/audio_folder). if (FolderDepth != -1) { int depth = FolderDepth; string album_artist = FileNamePattern.Escape(track.DisplayAlbumArtistName); string track_album = FileNamePattern.Escape(track.DisplayAlbumTitle); string track_number = FileNamePattern.Escape(Convert.ToString(track.TrackNumber)); string track_title = FileNamePattern.Escape(track.DisplayTrackTitle); if (depth == 0) { // Artist - Album - 01 - Title string track_artist = FileNamePattern.Escape(track.DisplayArtistName); file_path = String.Format("{0} - {1} - {2} - {3}", track_artist, track_album, track_number, track_title); } else if (depth == 1) { // Artist - Album/01 - Title file_path = String.Format("{0} - {1}", album_artist, track_album); file_path = System.IO.Path.Combine(file_path, String.Format("{0} - {1}", track_number, track_title)); } else if (depth == 2) { // Artist/Album/01 - Title file_path = album_artist; file_path = System.IO.Path.Combine(file_path, track_album); file_path = System.IO.Path.Combine(file_path, String.Format("{0} - {1}", track_number, track_title)); } else { // If the *required* depth is more than 2..go nuts! for (int i = 0; i < depth - 2; i++) { if (i == 0) { file_path = album_artist.Substring(0, Math.Min(i + 1, album_artist.Length)).Trim(); } else { file_path = System.IO.Path.Combine(file_path, album_artist.Substring(0, Math.Min(i + 1, album_artist.Length)).Trim()); } } // Finally add on the Artist/Album/01 - Track file_path = System.IO.Path.Combine(file_path, album_artist); file_path = System.IO.Path.Combine(file_path, track_album); file_path = System.IO.Path.Combine(file_path, String.Format("{0} - {1}", track_number, track_title)); } } else { file_path = FileNamePattern.CreateFromTrackInfo(track); } } if (track.HasAttribute(TrackMediaAttributes.VideoStream)) { file_path = System.IO.Path.Combine(WritePathVideo, file_path); } else { file_path = System.IO.Path.Combine(WritePath, file_path); } file_path += ext; return(file_path); }