From c25103edfb1681811457d7eaceae294ad6cebaa4 Mon Sep 17 00:00:00 2001 From: Steven Hildreth Date: Mon, 5 Nov 2018 21:56:46 -0600 Subject: [PATCH] WIP --- .../Subsonic/ALbumInfoResponse.cs | 66 ++++++ .../Models/ThirdPartyApi/Subsonic/Album.cs | 198 +++++++++++++++++ .../ThirdPartyApi/Subsonic/AlbumResponse.cs | 101 +++++++++ .../Models/ThirdPartyApi/Subsonic/Artist.cs | 98 +++++++++ .../Subsonic/ArtistInfo2Response.cs | 55 +++++ .../ThirdPartyApi/Subsonic/ArtistResponse.cs | 32 +++ .../ThirdPartyApi/Subsonic/BaseResponse.cs | 26 +++ .../Models/ThirdPartyApi/Subsonic/Child.cs | 59 +++++ .../ThirdPartyApi/Subsonic/Credentials.cs | 35 +++ .../ThirdPartyApi/Subsonic/Directory.cs | 24 +++ .../Models/ThirdPartyApi/Subsonic/Entry.cs | 67 ++++++ .../ThirdPartyApi/Subsonic/ErrorCodes.cs | 86 ++++++++ .../Models/ThirdPartyApi/Subsonic/Genres.cs | 56 +++++ .../Models/ThirdPartyApi/Subsonic/Indexes.cs | 94 ++++++++ .../Models/ThirdPartyApi/Subsonic/License.cs | 37 ++++ .../ThirdPartyApi/Subsonic/LicenseReponse.cs | 33 +++ .../ThirdPartyApi/Subsonic/LyricResponse.cs | 40 ++++ .../Subsonic/MusicDirectories.cs | 110 ++++++++++ .../ThirdPartyApi/Subsonic/MusicFolders.cs | 55 +++++ .../Models/ThirdPartyApi/Subsonic/Ping.cs | 25 +++ .../Models/ThirdPartyApi/Subsonic/Playlist.cs | 156 ++++++++++++++ .../Models/ThirdPartyApi/Subsonic/Podcasts.cs | 146 +++++++++++++ .../Subsonic/RandomSongResponse.cs | 40 ++++ .../ThirdPartyApi/Subsonic/Search2Response.cs | 70 ++++++ .../Models/ThirdPartyApi/Subsonic/Shortcut.cs | 18 ++ .../Models/ThirdPartyApi/Subsonic/Song.cs | 204 ++++++++++++++++++ .../ThirdPartyApi/Subsonic/SongResponse.cs | 33 +++ .../Subsonic/SongsByGenreResponse.cs | 45 ++++ .../Subsonic/Starred2Response.cs | 72 +++++++ .../ThirdPartyApi/Subsonic/UserResponse.cs | 159 ++++++++++++++ RoadieLibrary/Roadie.Library.csproj | 3 + RoadieLibrary/Utility/EmailHelper.cs | 36 ++++ RoadieLibrary/Utility/FtpHelper.cs | 47 ++++ 33 files changed, 2326 insertions(+) create mode 100644 RoadieLibrary/Models/ThirdPartyApi/Subsonic/ALbumInfoResponse.cs create mode 100644 RoadieLibrary/Models/ThirdPartyApi/Subsonic/Album.cs create mode 100644 RoadieLibrary/Models/ThirdPartyApi/Subsonic/AlbumResponse.cs create mode 100644 RoadieLibrary/Models/ThirdPartyApi/Subsonic/Artist.cs create mode 100644 RoadieLibrary/Models/ThirdPartyApi/Subsonic/ArtistInfo2Response.cs create mode 100644 RoadieLibrary/Models/ThirdPartyApi/Subsonic/ArtistResponse.cs create mode 100644 RoadieLibrary/Models/ThirdPartyApi/Subsonic/BaseResponse.cs create mode 100644 RoadieLibrary/Models/ThirdPartyApi/Subsonic/Child.cs create mode 100644 RoadieLibrary/Models/ThirdPartyApi/Subsonic/Credentials.cs create mode 100644 RoadieLibrary/Models/ThirdPartyApi/Subsonic/Directory.cs create mode 100644 RoadieLibrary/Models/ThirdPartyApi/Subsonic/Entry.cs create mode 100644 RoadieLibrary/Models/ThirdPartyApi/Subsonic/ErrorCodes.cs create mode 100644 RoadieLibrary/Models/ThirdPartyApi/Subsonic/Genres.cs create mode 100644 RoadieLibrary/Models/ThirdPartyApi/Subsonic/Indexes.cs create mode 100644 RoadieLibrary/Models/ThirdPartyApi/Subsonic/License.cs create mode 100644 RoadieLibrary/Models/ThirdPartyApi/Subsonic/LicenseReponse.cs create mode 100644 RoadieLibrary/Models/ThirdPartyApi/Subsonic/LyricResponse.cs create mode 100644 RoadieLibrary/Models/ThirdPartyApi/Subsonic/MusicDirectories.cs create mode 100644 RoadieLibrary/Models/ThirdPartyApi/Subsonic/MusicFolders.cs create mode 100644 RoadieLibrary/Models/ThirdPartyApi/Subsonic/Ping.cs create mode 100644 RoadieLibrary/Models/ThirdPartyApi/Subsonic/Playlist.cs create mode 100644 RoadieLibrary/Models/ThirdPartyApi/Subsonic/Podcasts.cs create mode 100644 RoadieLibrary/Models/ThirdPartyApi/Subsonic/RandomSongResponse.cs create mode 100644 RoadieLibrary/Models/ThirdPartyApi/Subsonic/Search2Response.cs create mode 100644 RoadieLibrary/Models/ThirdPartyApi/Subsonic/Shortcut.cs create mode 100644 RoadieLibrary/Models/ThirdPartyApi/Subsonic/Song.cs create mode 100644 RoadieLibrary/Models/ThirdPartyApi/Subsonic/SongResponse.cs create mode 100644 RoadieLibrary/Models/ThirdPartyApi/Subsonic/SongsByGenreResponse.cs create mode 100644 RoadieLibrary/Models/ThirdPartyApi/Subsonic/Starred2Response.cs create mode 100644 RoadieLibrary/Models/ThirdPartyApi/Subsonic/UserResponse.cs create mode 100644 RoadieLibrary/Utility/EmailHelper.cs create mode 100644 RoadieLibrary/Utility/FtpHelper.cs diff --git a/RoadieLibrary/Models/ThirdPartyApi/Subsonic/ALbumInfoResponse.cs b/RoadieLibrary/Models/ThirdPartyApi/Subsonic/ALbumInfoResponse.cs new file mode 100644 index 0000000..8a5a145 --- /dev/null +++ b/RoadieLibrary/Models/ThirdPartyApi/Subsonic/ALbumInfoResponse.cs @@ -0,0 +1,66 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.Serialization; +using System.Text; +using System.Threading.Tasks; +using System.Xml.Serialization; + +namespace Roadie.Models.ThirdPartyApi.Subsonic +{ + [DataContract] + [XmlRoot(ElementName = "subsonic-response", Namespace = "http://subsonic.org/restapi")] + public class AlbumInfoXmlResponse : BaseResponse + { + [XmlElement(ElementName = "albumInfo")] + public albuminfo albumInfo { get; set; } + } + + [DataContract] + public class AlbumInfoJsonResponseWrapper + { + [DataMember(Name = "subsonic-response")] + public AlbumInfoResponse subsonicresponse { get; set; } + } + + [DataContract] + public class AlbumInfoResponse : BaseResponse + { + [DataMember(Name = "albumInfo")] + public albuminfo albumInfo { get; set; } + } + + [DataContract] + public class albuminfo + { + [DataMember(Name = "notes")] + [XmlTextAttribute()] + public string notes { get; set; } + + [DataMember(Name = "musicBrainzId")] + [XmlElement(ElementName = "musicBrainzId")] + public string musicBrainzId { get; set; } + + [DataMember(Name = "lastFmUrl")] + [XmlElement(ElementName = "lastFmUrl")] + public string lastFmUrl { get; set; } + + [DataMember(Name = "smallImageUrl")] + [XmlElement(ElementName = "smallImageUrl")] + public string smallImageUrl { get; set; } + + [DataMember(Name = "mediumImageUrl")] + [XmlElement(ElementName = "mediumImageUrl")] + public string mediumImageUrl { get; set; } + + [DataMember(Name = "largeImageUrl")] + [XmlElement(ElementName = "largeImageUrl")] + public string largeImageUrl { get; set; } + + + } + + + + +} diff --git a/RoadieLibrary/Models/ThirdPartyApi/Subsonic/Album.cs b/RoadieLibrary/Models/ThirdPartyApi/Subsonic/Album.cs new file mode 100644 index 0000000..61a25ff --- /dev/null +++ b/RoadieLibrary/Models/ThirdPartyApi/Subsonic/Album.cs @@ -0,0 +1,198 @@ +using System; +using System.Diagnostics; +using System.Runtime.Serialization; +using System.Xml.Serialization; + +namespace Roadie.Models.ThirdPartyApi.Subsonic +{ + [DataContract] + [DebuggerDisplay("Title [{title}], PlayCount [{playCount}]")] + public class album + { + /// + /// Database ID + /// + [XmlIgnore] + public int ID { get; set; } + + [DataMember(Name = "id")] + [XmlAttribute(AttributeName = "id")] + public string id { get; set; } + + [DataMember(Name = "userRating")] + [XmlAttribute(AttributeName = "userRating")] + public short userRating { get; set; } + + [DataMember(Name = "averageRating")] + [XmlAttribute(AttributeName = "averageRating")] + public short averageRating { get; set; } + + [DataMember(Name = "playCount")] + [XmlAttribute(AttributeName = "playCount")] + public int playCount { get; set; } + + [DataMember(Name = "parent")] + [XmlAttribute(AttributeName = "parent")] + public string parent { get; set; } + + [DataMember(Name = "title")] + [XmlAttribute(AttributeName = "title")] + public string title { get; set; } + + [DataMember(Name = "genre")] + [XmlAttribute(AttributeName = "genre")] + public string genre { get; set; } + + [DataMember(Name = "album")] + [XmlAttribute(AttributeName = "album")] + public string albumTitle + { + get + { + return this.title; + } + } + + [DataMember(Name = "year")] + [XmlAttribute(AttributeName = "year")] + public int year + { + get + { + if (this.yearDateTime.HasValue) + { + return this.yearDateTime.Value.Year; + } + return 0; + } + set + { + } + } + + [XmlIgnore] + public DateTime? yearDateTime { get; set; } + + [DataMember(Name = "isDir")] + [XmlAttribute(AttributeName = "isDir")] + public bool isDir { get; set; } + + [DataMember(Name = "coverArt")] + [XmlAttribute(AttributeName = "coverArt")] + public string coverArt { get; set; } + + [DataMember(Name = "songCount")] + [XmlAttribute(AttributeName = "songCount")] + public int songCount { get; set; } + + [DataMember(Name = "created")] + [XmlAttribute(AttributeName = "created")] + public string created + { + get + { + if (this.createdDateTime.HasValue) + { + return this.createdDateTime.Value.ToString("s"); + } + return null; + } + set + { + } + } + + [XmlIgnore] + public DateTime? createdDateTime { get; set; } + + [XmlIgnore] + public DateTime? lastPlayed { get; set; } + + [DataMember(Name = "starred")] + [XmlAttribute(AttributeName = "starred")] + public string starred + { + get + { + if (this.starredDateTime.HasValue) + { + return this.starredDateTime.Value.ToString("s"); + } + return null; + } + set + { + } + } + + public bool ShouldSerializestarred() + { + return this.starredDateTime.HasValue; + } + + [XmlIgnore] + public DateTime? starredDateTime { get; set; } + + [DataMember(Name = "artist")] + [XmlAttribute(AttributeName = "artist")] + public string artist { get; set; } + + [DataMember(Name = "artistId")] + [XmlAttribute(AttributeName = "artistId")] + public string artistId { get; set; } + + [XmlIgnore] + public int artistID { get; set; } + + [DataMember(Name = "duration")] + [XmlAttribute(AttributeName = "duration")] + public int duration + { + get + { + if (this.durationMilliseconds > 0) + { + var contentDurationTimeSpan = TimeSpan.FromMilliseconds((double) (this.durationMilliseconds ?? 0)); + return (int) contentDurationTimeSpan.TotalSeconds; + } + return 0; + } + set + { + } + } + + [XmlIgnore] + public int? durationMilliseconds { get; set; } + + [XmlIgnore] + public int? listNumber { get; set; } + + [DataMember(Name = "song")] + [XmlElement(ElementName = "song")] + public song[] song { get; set; } + + public bool ShouldSerializesong() + { + return this.song != null; + } + + [XmlIgnore] + public string notes { get; set; } + + [XmlIgnore] + public string musicBrainzId { get; set; } + + [XmlIgnore] + public string lastFMUrl { get; set; } + + [XmlIgnore] + public string smallImageUrl { get; set; } + + [XmlIgnore] + public string mediumImageUrl { get; set; } + + [XmlIgnore] + public string largeImageUrl { get; set; } + } +} \ No newline at end of file diff --git a/RoadieLibrary/Models/ThirdPartyApi/Subsonic/AlbumResponse.cs b/RoadieLibrary/Models/ThirdPartyApi/Subsonic/AlbumResponse.cs new file mode 100644 index 0000000..2755899 --- /dev/null +++ b/RoadieLibrary/Models/ThirdPartyApi/Subsonic/AlbumResponse.cs @@ -0,0 +1,101 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.Serialization; +using System.Text; +using System.Threading.Tasks; +using System.Xml.Serialization; + +namespace Roadie.Models.ThirdPartyApi.Subsonic +{ + [Serializable] + [XmlRoot(ElementName = "subsonic-response", Namespace = "http://subsonic.org/restapi")] + public class AlbumListXmlResponse : BaseResponse + { + [XmlElement(ElementName = "albumList")] + public AlbumList albumList { get; set; } + } + + [Serializable] + [XmlRoot(ElementName = "subsonic-response", Namespace = "http://subsonic.org/restapi")] + public class AlbumXmlResponse : BaseResponse + { + [XmlElement(ElementName = "album")] + public album album { get; set; } + } + + [DataContract] + public class AlbumListJsonResponseWrapper + { + [DataMember(Name = "subsonic-response")] + public AlbumListJsonResponse subsonicresponse { get; set; } + } + + [DataContract] + [XmlRoot(ElementName = "subsonic-response", Namespace = "http://subsonic.org/restapi")] + public class AlbumListJsonResponse : BaseResponse + { + [DataMember(Name = "albumList")] + public AlbumList albumList { get; set; } + } + + [DataContract] + public class AlbumList + { + [DataMember(Name = "album")] + [XmlElement(ElementName = "album")] + public album[] album { get; set; } + } + + + + [DataContract] + public class AlbumJsonResponseWrapper + { + [DataMember(Name = "subsonic-response")] + public AlbumJsonResponse subsonicresponse { get; set; } + } + + + [DataContract] + [XmlRoot(ElementName = "subsonic-response", Namespace = "http://subsonic.org/restapi")] + public class AlbumJsonResponse : BaseResponse + { + [DataMember(Name = "album")] + public album album { get; set; } + } + + + + + + //public class Song + //{ + // public string id { get; set; } + // public string parent { get; set; } + // public bool isDir { get; set; } + // public string title { get; set; } + // public string album { get; set; } + // public string artist { get; set; } + // public int track { get; set; } + // public int year { get; set; } + // public string genre { get; set; } + // public string coverArt { get; set; } + // public int size { get; set; } + // public string contentType { get; set; } + // public string suffix { get; set; } + // public int duration { get; set; } + // public int bitRate { get; set; } + // public string path { get; set; } + // public int userRating { get; set; } + // public int averageRating { get; set; } + // public int playCount { get; set; } + // public DateTime created { get; set; } + // public DateTime starred { get; set; } + // public string albumId { get; set; } + // public string artistId { get; set; } + // public string type { get; set; } + //} + + +} diff --git a/RoadieLibrary/Models/ThirdPartyApi/Subsonic/Artist.cs b/RoadieLibrary/Models/ThirdPartyApi/Subsonic/Artist.cs new file mode 100644 index 0000000..2cb6b60 --- /dev/null +++ b/RoadieLibrary/Models/ThirdPartyApi/Subsonic/Artist.cs @@ -0,0 +1,98 @@ +using System; +using System.Runtime.Serialization; +using System.Xml.Serialization; + +namespace Roadie.Models.ThirdPartyApi.Subsonic +{ + [DataContract] + public class artist + { + /// + /// Database ID + /// + [XmlIgnore] + public int ID { get; set; } + + [DataMember(Name = "id")] + [XmlAttribute(AttributeName = "id")] + public string id { get; set; } + + [DataMember(Name = "name")] + [XmlAttribute(AttributeName = "name")] + public string name { get; set; } + + [DataMember(Name = "sortname")] + [XmlAttribute(AttributeName = "sortname")] + public string sortname { get; set; } + + [XmlIgnore] + public string biography { get; set; } + + [XmlIgnore] + public string musicBrainzId { get; set; } + + [XmlIgnore] + public string lastFMUrl { get; set; } + + [XmlIgnore] + public string smallImageUrl { get; set; } + + [XmlIgnore] + public string mediumImageUrl { get; set; } + + [XmlIgnore] + public string largeImageUrl { get; set; } + + [DataMember(Name = "genre")] + [XmlAttribute(AttributeName = "genre")] + public string genre { get; set; } + + [DataMember(Name = "starred")] + [XmlAttribute(AttributeName = "starred")] + public string starred + { + get + { + if (this.starredDateTime.HasValue) + { + return this.starredDateTime.Value.ToString("s"); + } + return null; + } + set + { + } + } + + public bool ShouldSerializestarred() + { + return this.starredDateTime.HasValue; + } + + [DataMember(Name = "coverArt")] + [XmlAttribute(AttributeName = "coverArt")] + public string coverArt { get; set; } + + [DataMember(Name = "albumCount")] + [XmlAttribute(AttributeName = "albumCount")] + public int albumCount { get; set; } + + [DataMember(Name = "userRating")] + [XmlAttribute(AttributeName = "userRating")] + public short userRating { get; set; } + + [XmlIgnore] + public DateTime? starredDateTime { get; set; } + [XmlIgnore] + public DateTime? createdDateTime { get; set; } + + [DataMember(Name = "album")] + [XmlElement(ElementName = "album")] + public album[] album { get; set; } + + public bool ShouldSerializealbum() + { + return this.album != null; + } + } +} \ No newline at end of file diff --git a/RoadieLibrary/Models/ThirdPartyApi/Subsonic/ArtistInfo2Response.cs b/RoadieLibrary/Models/ThirdPartyApi/Subsonic/ArtistInfo2Response.cs new file mode 100644 index 0000000..54bb577 --- /dev/null +++ b/RoadieLibrary/Models/ThirdPartyApi/Subsonic/ArtistInfo2Response.cs @@ -0,0 +1,55 @@ +using System.Runtime.Serialization; +using System.Xml.Serialization; + +namespace Roadie.Models.ThirdPartyApi.Subsonic +{ + [DataContract] + [XmlRoot(ElementName = "subsonic-response", Namespace = "http://subsonic.org/restapi")] + public class ArtistInfo2XmlResponse : BaseResponse + { + [XmlElement(ElementName = "artistInfo2")] + public artistinfo2 artistInfo2 { get; set; } + } + + [DataContract] + public class ArtistInfo2JsonResponseWrapper + { + [DataMember(Name = "subsonic-response")] + public ArtistInfo2Response subsonicresponse { get; set; } + } + + [DataContract] + public class ArtistInfo2Response : BaseResponse + { + [DataMember(Name = "artistInfo2")] + public artistinfo2 artistInfo2 { get; set; } + } + + [DataContract] + public class artistinfo2 + { + [DataMember(Name = "biography")] + [XmlElement(ElementName = "biography")] + public string biography { get; set; } + + [DataMember(Name = "musicBrainzId")] + [XmlElement(ElementName = "musicBrainzId")] + public string musicBrainzId { get; set; } + + [DataMember(Name = "lastFmUrl")] + [XmlElement(ElementName = "lastFmUrl")] + public string lastFmUrl { get; set; } + + [DataMember(Name = "smallImageUrl")] + [XmlElement(ElementName = "smallImageUrl")] + public string smallImageUrl { get; set; } + + [DataMember(Name = "mediumImageUrl")] + [XmlElement(ElementName = "mediumImageUrl")] + public string mediumImageUrl { get; set; } + + [DataMember(Name = "largeImageUrl")] + [XmlElement(ElementName = "largeImageUrl")] + public string largeImageUrl { get; set; } + } +} \ No newline at end of file diff --git a/RoadieLibrary/Models/ThirdPartyApi/Subsonic/ArtistResponse.cs b/RoadieLibrary/Models/ThirdPartyApi/Subsonic/ArtistResponse.cs new file mode 100644 index 0000000..fb82df9 --- /dev/null +++ b/RoadieLibrary/Models/ThirdPartyApi/Subsonic/ArtistResponse.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.Serialization; +using System.Text; +using System.Threading.Tasks; +using System.Xml.Serialization; + +namespace Roadie.Models.ThirdPartyApi.Subsonic +{ + [DataContract] + [XmlRoot(ElementName = "subsonic-response", Namespace = "http://subsonic.org/restapi")] + public class ArtistXmlResponse : BaseResponse + { + [XmlElement(ElementName = "artist")] + public artist artist { get; set; } + } + + [DataContract] + public class ArtistJsonResponseWrapper + { + [DataMember(Name = "subsonic-response")] + public ArtistResponse subsonicresponse { get; set; } + } + + [DataContract] + public class ArtistResponse : BaseResponse + { + [DataMember(Name = "artist")] + public artist artist { get; set; } + } +} diff --git a/RoadieLibrary/Models/ThirdPartyApi/Subsonic/BaseResponse.cs b/RoadieLibrary/Models/ThirdPartyApi/Subsonic/BaseResponse.cs new file mode 100644 index 0000000..33d72ab --- /dev/null +++ b/RoadieLibrary/Models/ThirdPartyApi/Subsonic/BaseResponse.cs @@ -0,0 +1,26 @@ +using System; +using System.Runtime.Serialization; +using System.Xml.Serialization; + +namespace Roadie.Models.ThirdPartyApi.Subsonic +{ + [Serializable] + [DataContract] + [XmlRoot(ElementName = "subsonic-response", Namespace = "http://subsonic.org/restapi")] + public class BaseResponse + { + [DataMember(Name = "status")] + [XmlAttribute(AttributeName = "status")] + public string status { get; set; } + + [DataMember(Name = "version")] + [XmlAttribute(AttributeName = "version")] + public string version { get; set; } + + public BaseResponse() + { + this.status = "ok"; + this.version = Credentials.API_VERSION; + } + } +} \ No newline at end of file diff --git a/RoadieLibrary/Models/ThirdPartyApi/Subsonic/Child.cs b/RoadieLibrary/Models/ThirdPartyApi/Subsonic/Child.cs new file mode 100644 index 0000000..35a6b7d --- /dev/null +++ b/RoadieLibrary/Models/ThirdPartyApi/Subsonic/Child.cs @@ -0,0 +1,59 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Xml.Serialization; + +namespace Roadie.Models.ThirdPartyApi.Subsonic +{ + [Serializable] + public class Child + { + [XmlAttribute(AttributeName = "id")] + public string id { get; set; } + [XmlAttribute(AttributeName = "parent")] + public string parent { get; set; } + [XmlAttribute(AttributeName = "title")] + public string title { get; set; } + /// + /// True when a Album + /// + [XmlAttribute(AttributeName = "isDir")] + public string isDir { get; set; } + [XmlAttribute(AttributeName = "album")] + public string album { get; set; } + [XmlAttribute(AttributeName = "artist")] + public string artist { get; set; } + [XmlAttribute(AttributeName = "track")] + public string track { get; set; } + [XmlAttribute(AttributeName = "year")] + public string year { get; set; } + [XmlAttribute(AttributeName = "genre")] + public string genre { get; set; } + [XmlAttribute(AttributeName = "coverArt")] + public string coverArt { get; set; } + [XmlAttribute(AttributeName = "size")] + public string size { get; set; } + [XmlAttribute(AttributeName = "contentType")] + public string contentType { get; set; } + [XmlAttribute(AttributeName = "transcodedContentType")] + public string transcodedContentType { get; set; } + [XmlAttribute(AttributeName = "suffix")] + public string suffix { get; set; } + [XmlAttribute(AttributeName = "transcodedSuffix")] + public string transcodedSuffix { get; set; } + [XmlAttribute(AttributeName = "duration")] + public string duration { get; set; } + [XmlAttribute(AttributeName = "bitRate")] + public string bitRate { get; set; } + [XmlAttribute(AttributeName = "path")] + public string path { get; set; } + + + public Child() + { + this.isDir = "false"; + } + } +} diff --git a/RoadieLibrary/Models/ThirdPartyApi/Subsonic/Credentials.cs b/RoadieLibrary/Models/ThirdPartyApi/Subsonic/Credentials.cs new file mode 100644 index 0000000..abb853c --- /dev/null +++ b/RoadieLibrary/Models/ThirdPartyApi/Subsonic/Credentials.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Roadie.Models.ThirdPartyApi.Subsonic +{ + [Serializable] + public class Credentials + { + public const string API_VERSION = "1.14.0"; + + public string version { get; set; } + public string appName { get; set; } + public string salt { get; set; } + public string user { get; set; } + //public string token + //{ + // get { return _token; } + // // set { _token = BitConverter.ToString(Encoding.UTF8.GetBytes(value)).Replace("-", ""); } + + //} + public string token { get; set; } + + public Credentials(string version, string appName, string user, string salt, string token) + { + this.version = version; + this.appName = appName; + this.user = user; + this.salt = salt; + this.token = token; + } + } +} diff --git a/RoadieLibrary/Models/ThirdPartyApi/Subsonic/Directory.cs b/RoadieLibrary/Models/ThirdPartyApi/Subsonic/Directory.cs new file mode 100644 index 0000000..9070775 --- /dev/null +++ b/RoadieLibrary/Models/ThirdPartyApi/Subsonic/Directory.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Xml.Serialization; + +namespace Roadie.Models.ThirdPartyApi.Subsonic +{ + [Serializable] + public class Directory + { + [XmlAttribute(AttributeName = "id")] + public string id { get; set; } + [XmlAttribute(AttributeName = "parent")] + public string parent { get; set; } + [XmlAttribute(AttributeName = "name")] + public string name { get; set; } + [XmlAttribute(AttributeName = "starred")] + public string starred { get; set; } + [XmlElement(ElementName = "child")] + public Child[] child { get; set; } + } +} diff --git a/RoadieLibrary/Models/ThirdPartyApi/Subsonic/Entry.cs b/RoadieLibrary/Models/ThirdPartyApi/Subsonic/Entry.cs new file mode 100644 index 0000000..b635f1c --- /dev/null +++ b/RoadieLibrary/Models/ThirdPartyApi/Subsonic/Entry.cs @@ -0,0 +1,67 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Xml.Serialization; + +namespace Roadie.Models.ThirdPartyApi.Subsonic +{ + [Serializable] + public class Entry + { + [XmlAttribute(AttributeName = "username")] + public string username { get; set; } + + [XmlAttribute(AttributeName = "minutesAgo")] + public string minutesAgo { get; set; } + + [XmlAttribute(AttributeName = "playerId")] + public string playerId { get; set; } + [XmlAttribute(AttributeName = "playerName")] + public string playerName { get; set; } + + [XmlAttribute(AttributeName = "id")] + public string id { get; set; } + + [XmlAttribute(AttributeName = "parent")] + public string parent { get; set; } + + [XmlAttribute(AttributeName = "title")] + public string title { get; set; } + + [XmlAttribute(AttributeName = "isDir")] + public string isDir { get; set; } + + [XmlAttribute(AttributeName = "album")] + public string album { get; set; } + + [XmlAttribute(AttributeName = "artist")] + public string artist { get; set; } + + [XmlAttribute(AttributeName = "track")] + public string track { get; set; } + + [XmlAttribute(AttributeName = "year")] + public string year { get; set; } + + [XmlAttribute(AttributeName = "genre")] + public string genre { get; set; } + + [XmlAttribute(AttributeName = "coverArt")] + public string coverArt { get; set; } + + [XmlAttribute(AttributeName = "size")] + public string size { get; set; } + [XmlAttribute(AttributeName = "contentType")] + public string contentType { get; set; } + [XmlAttribute(AttributeName = "suffix")] + public string suffix { get; set; } + [XmlAttribute(AttributeName = "path")] + public string path { get; set; } + [XmlAttribute(AttributeName = "transcodedContentType")] + public string transcodedContentType { get; set; } + [XmlAttribute(AttributeName = "transcodedSuffix")] + public string transcodedSuffix { get; set; } + } +} diff --git a/RoadieLibrary/Models/ThirdPartyApi/Subsonic/ErrorCodes.cs b/RoadieLibrary/Models/ThirdPartyApi/Subsonic/ErrorCodes.cs new file mode 100644 index 0000000..dd36e07 --- /dev/null +++ b/RoadieLibrary/Models/ThirdPartyApi/Subsonic/ErrorCodes.cs @@ -0,0 +1,86 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.Serialization; +using System.Text; +using System.Threading.Tasks; +using System.Xml.Serialization; + +namespace Roadie.Models.ThirdPartyApi.Subsonic +{ + + [DataContract] + [XmlRoot(ElementName = "subsonic-response", Namespace = "http://subsonic.org/restapi")] + public class ErrorXmlResponse : BaseResponse + { + [XmlElement(ElementName = "error")] + public error error { get; set; } + } + + + public class ErrorJsonResponseWrapper + { + [DataMember(Name = "subsonic-response")] + public ErrorJsonResponse subsonicresponse { get; set; } + } + + public class ErrorJsonResponse : BaseResponse + { + [DataMember(Name = "error")] + public error error { get; set; } + } + + + public static class ErrorCodeHelper + { + public static error WrongUserNameOrPassword() + { + return ErrorCodeHelper.ErrorCodes().First(x => x.code == 40); + } + + public static error RequestedDataNotFound() + { + return ErrorCodeHelper.ErrorCodes().First(x => x.code == 70); + } + + public static error UserNotAuthorized() + { + return ErrorCodeHelper.ErrorCodes().First(x => x.code == 50); + } + + public static error GenericError() + { + return ErrorCodeHelper.ErrorCodes().First(x => x.code == 0); + } + + public static error RequiredParameterMissing() + { + return ErrorCodeHelper.ErrorCodes().First(x => x.code == 10); + } + + public static List ErrorCodes() + { + return new List + { + new error { code = 0, message = "A generic error." }, + new error { code = 10, message = "Required parameter is missing." }, + new error { code = 20, message = "Incompatible Subsonic REST protocol version. Client must upgrade." }, + new error { code = 30, message = "Incompatible Subsonic REST protocol version. Server must upgrade." }, + new error { code = 40, message = "Wrong username or password." }, + new error { code = 41, message = "Token authentication not supported for LDAP users." }, + new error { code = 50, message = "User is not authorized for the given operation." }, + new error { code = 60, message = "The trial period for the Subsonic server is over. Please upgrade to Subsonic Premium. Visit subsonic.org for details." }, + new error { code = 70, message = "The requested data was not found." } + }; + } + } + + + public class error + { + public int code { get; set; } + public string message { get; set; } + } + + +} diff --git a/RoadieLibrary/Models/ThirdPartyApi/Subsonic/Genres.cs b/RoadieLibrary/Models/ThirdPartyApi/Subsonic/Genres.cs new file mode 100644 index 0000000..b852254 --- /dev/null +++ b/RoadieLibrary/Models/ThirdPartyApi/Subsonic/Genres.cs @@ -0,0 +1,56 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.Serialization; +using System.Text; +using System.Threading.Tasks; +using System.Xml.Serialization; + +namespace Roadie.Models.ThirdPartyApi.Subsonic +{ + + [DataContract] + [XmlRoot(ElementName = "subsonic-response", Namespace = "http://subsonic.org/restapi")] + public class GenresXMLResponse : BaseResponse + { + [DataMember(Name = "genres")] + public genre[] genres { get; set; } + } + + [DataContract] + public class GenresJsonResponseWrapper + { + [DataMember(Name = "subsonic-response")] + public GenresJsonResponse subsonicresponse { get; set; } + } + + [DataContract] + [XmlRoot(ElementName = "subsonic-response", Namespace = "http://subsonic.org/restapi")] + public class GenresJsonResponse : BaseResponse + { + [DataMember(Name = "genres")] + public Genres genres { get; set; } + } + + + [DataContract] + public class Genres + { + [DataMember(Name = "genre")] + [XmlElement(ElementName = "genre")] + public genre[] genre { get; set; } + } + [DataContract] + public class genre + { + [DataMember(Name = "songCount")] + [XmlAttribute(AttributeName = "songCount")] + public int songCount { get; set; } + [DataMember(Name = "albumCount")] + [XmlAttribute(AttributeName = "albumCount")] + public int albumCount { get; set; } + [DataMember(Name = "value")] + [XmlText] + public string value { get; set; } + } +} diff --git a/RoadieLibrary/Models/ThirdPartyApi/Subsonic/Indexes.cs b/RoadieLibrary/Models/ThirdPartyApi/Subsonic/Indexes.cs new file mode 100644 index 0000000..6920697 --- /dev/null +++ b/RoadieLibrary/Models/ThirdPartyApi/Subsonic/Indexes.cs @@ -0,0 +1,94 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.Serialization; +using System.Text; +using System.Threading.Tasks; +using System.Xml.Serialization; + +namespace Roadie.Models.ThirdPartyApi.Subsonic +{ + [DataContract] + [XmlRoot(ElementName = "subsonic-response", Namespace = "http://subsonic.org/restapi")] + public class IndexXMLResponse : BaseResponse + { + [XmlElement(ElementName = "indexes")] + public Indexes indexes { get; set; } + } + + [DataContract] + [XmlRoot(ElementName = "subsonic-response", Namespace = "http://subsonic.org/restapi")] + public class ArtistsXmlResponse : BaseResponse + { + [XmlElement(ElementName = "artists")] + public artists artists { get; set; } + } + + [DataContract] + public class IndexJsonResponseWrapper + { + [DataMember(Name = "subsonic-response")] + public IndexJsonResponse subsonicresponse { get; set; } + } + + [DataContract] + public class IndexJsonResponse : BaseResponse + { + [DataMember(Name = "indexes")] + public Indexes indexes { get; set; } + } + + [DataContract] + public class ArtistsJsonResponseWrapper + { + [DataMember(Name = "subsonic-response")] + public ArtistsJsonResponse subsonicresponse { get; set; } + } + + [DataContract] + public class ArtistsJsonResponse : BaseResponse + { + [DataMember(Name = "artists")] + public artists artists { get; set; } + } + + [DataContract] + public class artists + { + [DataMember(Name = "lastModified")] + [XmlAttribute(AttributeName = "lastModified")] + public string lastModified { get; set; } + [DataMember(Name = "ignoredArticles")] + [XmlAttribute(AttributeName = "ignoredArticles")] + public string ignoredArticles { get; set; } + [XmlElement(ElementName = "index")] + [DataMember(Name = "index")] + public Index[] index { get; set; } + } + + [DataContract] + public class Indexes + { + [DataMember(Name = "lastModified")] + [XmlAttribute(AttributeName = "lastModified")] + public string lastModified { get; set; } + [DataMember(Name = "ignoredArticles")] + [XmlAttribute(AttributeName = "ignoredArticles")] + public string ignoredArticles { get; set; } + [XmlElement(ElementName = "index")] + [DataMember(Name = "index")] + public Index[] index { get; set; } + } + + [DataContract] + public class Index + { + [DataMember(Name = "name")] + [XmlAttribute(AttributeName = "name")] + public string name { get; set; } + [XmlElement(ElementName = "artist")] + [DataMember(Name = "artist")] + public artist[] artist { get; set; } + } + +} diff --git a/RoadieLibrary/Models/ThirdPartyApi/Subsonic/License.cs b/RoadieLibrary/Models/ThirdPartyApi/Subsonic/License.cs new file mode 100644 index 0000000..825b388 --- /dev/null +++ b/RoadieLibrary/Models/ThirdPartyApi/Subsonic/License.cs @@ -0,0 +1,37 @@ +using Roadie.Library.Configuration; +using Roadie.Library.Utility; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.Serialization; +using System.Text; +using System.Threading.Tasks; +using System.Xml.Serialization; + +namespace Roadie.Models.ThirdPartyApi.Subsonic +{ + [DataContract] + public class License + { + [DataMember(Name = "valid")] + [XmlAttribute(AttributeName = "valid")] + public bool valid { get; set; } + [DataMember(Name = "email")] + [XmlAttribute(AttributeName = "email")] + public string email { get; set; } + [DataMember(Name = "key")] + [XmlAttribute(AttributeName = "key")] + public string key { get; set; } + [DataMember(Name = "licenseExpires")] + [XmlAttribute(AttributeName = "licenseExpires")] + public string licenseExpires { get; set; } + + public License(IRoadieSettings configuration) + { + this.valid = true; + this.email = configuration.SmtpFromAddress; + this.key = "C617BEA251B9E2C03DCF7289"; + this.licenseExpires = DateTime.UtcNow.AddYears(5).ToString("s"); + } + } +} diff --git a/RoadieLibrary/Models/ThirdPartyApi/Subsonic/LicenseReponse.cs b/RoadieLibrary/Models/ThirdPartyApi/Subsonic/LicenseReponse.cs new file mode 100644 index 0000000..f581043 --- /dev/null +++ b/RoadieLibrary/Models/ThirdPartyApi/Subsonic/LicenseReponse.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.Serialization; +using System.Text; +using System.Threading.Tasks; +using System.Xml.Serialization; + +namespace Roadie.Models.ThirdPartyApi.Subsonic +{ + [DataContract] + [XmlRoot(ElementName = "subsonic-response", Namespace = "http://subsonic.org/restapi")] + public class LicenseXmlResponse : BaseResponse + { + [XmlElement(ElementName = "license")] + public License license { get; set; } + } + + [DataContract] + public class LicenseJsonResponseWrapper + { + [DataMember(Name = "subsonic-response")] + public LicenseJsonResponse subsonicresponse { get; set; } + } + + [DataContract] + [XmlRoot(ElementName = "subsonic-response", Namespace = "http://subsonic.org/restapi")] + public class LicenseJsonResponse : BaseResponse + { + [DataMember(Name = "license")] + public License license { get; set; } + } +} diff --git a/RoadieLibrary/Models/ThirdPartyApi/Subsonic/LyricResponse.cs b/RoadieLibrary/Models/ThirdPartyApi/Subsonic/LyricResponse.cs new file mode 100644 index 0000000..d48dda2 --- /dev/null +++ b/RoadieLibrary/Models/ThirdPartyApi/Subsonic/LyricResponse.cs @@ -0,0 +1,40 @@ +using System.Runtime.Serialization; +using System.Xml.Serialization; + +namespace Roadie.Models.ThirdPartyApi.Subsonic +{ + [DataContract] + [XmlRoot(ElementName = "subsonic-response", Namespace = "http://subsonic.org/restapi")] + public class LyricXMLResponse : BaseResponse + { + [XmlElement(ElementName = "lyrics")] + public Lyric lyrics { get; set; } + } + + public class LyricJsonResponseWrapper + { + [DataMember(Name = "subsonic-response")] + public LyricJsonResponse subsonicresponse { get; set; } + } + + public class LyricJsonResponse : BaseResponse + { + [DataMember(Name = "lyrics")] + public Lyric lyrics { get; set; } + } + + public class Lyric + { + [DataMember(Name = "artist")] + [XmlAttribute(AttributeName = "artist")] + public string artist { get; set; } + + [DataMember(Name = "title")] + [XmlAttribute(AttributeName = "title")] + public string title { get; set; } + + [DataMember(Name = "value")] + [XmlTextAttribute()] + public string value { get; set; } + } +} \ No newline at end of file diff --git a/RoadieLibrary/Models/ThirdPartyApi/Subsonic/MusicDirectories.cs b/RoadieLibrary/Models/ThirdPartyApi/Subsonic/MusicDirectories.cs new file mode 100644 index 0000000..97faa38 --- /dev/null +++ b/RoadieLibrary/Models/ThirdPartyApi/Subsonic/MusicDirectories.cs @@ -0,0 +1,110 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.Serialization; +using System.Text; +using System.Threading.Tasks; +using System.Xml.Serialization; + +namespace Roadie.Models.ThirdPartyApi.Subsonic +{ + [DataContract] + [XmlRoot(ElementName = "subsonic-response", Namespace = "http://subsonic.org/restapi")] + public class ArtistDirectoryXmlResponse : BaseResponse + { + [DataMember(Name = "directory")] + public artistAlbumDirectory directory { get; set; } + } + + [DataContract] + [XmlRoot(ElementName = "subsonic-response", Namespace = "http://subsonic.org/restapi")] + public class AlbumSongDirectoryXmlResponse : BaseResponse + { + [DataMember(Name = "directory")] + public albumSongDirectory directory { get; set; } + } + + [DataContract] + public class ArtistDirectoryJsonResponseWrapper + { + [DataMember(Name = "subsonic-response")] + public ArtistDirectoryJsonResponse subsonicresponse { get; set; } + } + + [DataContract] + public class AlbumDirectoryJsonResponseWrapper + { + [DataMember(Name = "subsonic-response")] + public AlbumDirectoryJsonResponse subsonicresponse { get; set; } + } + + [DataContract] + [XmlRoot(ElementName = "subsonic-response", Namespace = "http://subsonic.org/restapi")] + public class ArtistDirectoryJsonResponse : BaseResponse + { + [DataMember(Name = "directory")] + public artistAlbumDirectory directory { get; set; } + } + + [DataContract] + [XmlRoot(ElementName = "subsonic-response", Namespace = "http://subsonic.org/restapi")] + public class AlbumDirectoryJsonResponse : BaseResponse + { + [DataMember(Name = "directory")] + public albumSongDirectory directory { get; set; } + } + + [DataContract] + public class directory + { + [DataMember(Name = "id")] + [XmlAttribute(AttributeName = "id")] + public string id { get; set; } + [DataMember(Name = "name")] + [XmlAttribute(AttributeName = "name")] + public string name { get; set; } + [DataMember(Name = "starred")] + [XmlAttribute(AttributeName = "starred")] + public string starred + { + get + { + if (this.starredDateTime.HasValue) + { + return this.starredDateTime.Value.ToString("s"); + } + return null; + } + } + public DateTime? starredDateTime { get; set; } + + } + + /// + /// Get the Albums for an Artist + /// + [DataContract] + public class artistAlbumDirectory : directory + { + [DataMember(Name = "child")] + [XmlElement(ElementName = "child")] + public album[] child { get; set; } + } + + /// + /// Get the songs for an Album + /// + [DataContract] + public class albumSongDirectory : directory + { + [DataMember(Name = "averageRating")] + [XmlAttribute(AttributeName = "averageRating")] + public decimal averageRating { get; set; } + [DataMember(Name = "playCount")] + [XmlAttribute(AttributeName = "playCount")] + public int playCount { get; set; } + [DataMember(Name = "child")] + [XmlElement(ElementName = "child")] + public song[] child { get; set; } + } +} diff --git a/RoadieLibrary/Models/ThirdPartyApi/Subsonic/MusicFolders.cs b/RoadieLibrary/Models/ThirdPartyApi/Subsonic/MusicFolders.cs new file mode 100644 index 0000000..bedaabf --- /dev/null +++ b/RoadieLibrary/Models/ThirdPartyApi/Subsonic/MusicFolders.cs @@ -0,0 +1,55 @@ +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.Serialization; +using System.ServiceModel; +using System.Text; +using System.Threading.Tasks; +using System.Xml.Serialization; + +namespace Roadie.Models.ThirdPartyApi.Subsonic +{ + [DataContract] + [XmlRoot(ElementName = "subsonic-response", Namespace = "http://subsonic.org/restapi")] + public class MusicFoldersXmlResponse : BaseResponse + { + [DataMember(Name = "musicFolders")] + public musicFolder[] musicFolders { get; set; } + } + + [DataContract] + public class MusicFoldersJsonResponseWrapper + { + [DataMember(Name = "subsonic-response")] + public MusicFoldersJsonResponse subsonicresponse { get; set; } + } + + [DataContract] + [XmlRoot(ElementName = "subsonic-response", Namespace = "http://subsonic.org/restapi")] + public class MusicFoldersJsonResponse : BaseResponse + { + [DataMember(Name = "musicFolders")] + public Musicfolders musicFolders { get; set; } + } + + [DataContract] + public class Musicfolders + { + [DataMember(Name = "musicFolder")] + public musicFolder[] musicFolder { get; set; } + } + + [DataContract] + public class musicFolder + { + [DataMember(Name = "id")] + [XmlAttribute] + public int id { get; set; } + [DataMember(Name = "name")] + [XmlAttribute] + public string name { get; set; } + } + + +} diff --git a/RoadieLibrary/Models/ThirdPartyApi/Subsonic/Ping.cs b/RoadieLibrary/Models/ThirdPartyApi/Subsonic/Ping.cs new file mode 100644 index 0000000..e892f07 --- /dev/null +++ b/RoadieLibrary/Models/ThirdPartyApi/Subsonic/Ping.cs @@ -0,0 +1,25 @@ +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.Serialization; +using System.Text; +using System.Threading.Tasks; +using System.Xml.Serialization; + +namespace Roadie.Models.ThirdPartyApi.Subsonic +{ + + [DataContract] + [XmlRoot(ElementName = "subsonic-response", Namespace = "http://subsonic.org/restapi")] + public class PingXmlResponse : BaseResponse + { + } + + [DataContract] + public class PingJsonResponse + { + [DataMember(Name = "subsonic-response")] + public BaseResponse subsonicresponse { get; set; } + } +} diff --git a/RoadieLibrary/Models/ThirdPartyApi/Subsonic/Playlist.cs b/RoadieLibrary/Models/ThirdPartyApi/Subsonic/Playlist.cs new file mode 100644 index 0000000..148bf2c --- /dev/null +++ b/RoadieLibrary/Models/ThirdPartyApi/Subsonic/Playlist.cs @@ -0,0 +1,156 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.Serialization; +using System.Text; +using System.Threading.Tasks; +using System.Xml.Serialization; + +namespace Roadie.Models.ThirdPartyApi.Subsonic +{ + [DataContract] + [XmlRoot(ElementName = "subsonic-response", Namespace = "http://subsonic.org/restapi")] + public class PlaylistsXMLResponse : BaseResponse + { + [XmlElement(ElementName = "playlists")] + public Playlists playlists { get; set; } + } + + [DataContract] + [XmlRoot(ElementName = "subsonic-response", Namespace = "http://subsonic.org/restapi")] + public class PlaylistXMLResponse : BaseResponse + { + [XmlElement(ElementName = "playlist")] + public Playlist playlist { get; set; } + } + + [DataContract] + public class PlaylistsJsonResponseWrapper + { + [DataMember(Name = "subsonic-response")] + public PlaylistsJsonResponse subsonicresponse { get; set; } + } + + [DataContract] + public class PlaylistJsonResponseWrapper + { + [DataMember(Name = "subsonic-response")] + public PlaylistJsonResponse subsonicresponse { get; set; } + } + + [DataContract] + public class PlaylistsJsonResponse : BaseResponse + { + [DataMember(Name = "playlists")] + public Playlists playlists { get; set; } + } + + [DataContract] + public class PlaylistJsonResponse : BaseResponse + { + [DataMember(Name = "playlist")] + public Playlist playlist { get; set; } + } + + [DataContract] + public class Playlists + { + [DataMember(Name = "playlist")] + [XmlElement(ElementName = "playlist")] + public Playlist[] playlist { get; set; } + } + + [DataContract] + public class Playlist + { + /// + /// Database ID + /// + [XmlIgnore] + public int ID { get; set; } + + [DataMember(Name = "id")] + [XmlAttribute(AttributeName = "id")] + public string id { get; set; } + [DataMember(Name = "name")] + [XmlAttribute(AttributeName = "name")] + public string name { get; set; } + [DataMember(Name = "comment")] + [XmlAttribute(AttributeName = "comment")] + public string comment { get; set; } + [DataMember(Name = "owner")] + [XmlAttribute(AttributeName = "owner")] + public string owner { get; set; } + [DataMember(Name = "isPublic")] + [XmlAttribute(AttributeName = "public")] + public bool isPublic { get; set; } + [DataMember(Name = "songCount")] + [XmlAttribute(AttributeName = "songCount")] + public int songCount { get; set; } + [DataMember(Name = "duration")] + [XmlAttribute(AttributeName = "duration")] + public int duration + { + get + { + var contentDurationTimeSpan = TimeSpan.FromMilliseconds((double) (durationMilliseconds)); + return (int) contentDurationTimeSpan.TotalSeconds; + } + } + + public int durationMilliseconds { get; set; } + [DataMember(Name = "created")] + [XmlAttribute(AttributeName = "created")] + public string created + { + get + { + if (this.createdDateTime.HasValue) + { + return this.createdDateTime.Value.ToString("s"); + } + return null; + } + set + { + } + } + public DateTime? createdDateTime { get; set; } + [DataMember(Name = "changed")] + [XmlAttribute(AttributeName = "changed")] + public string changed + { + get + { + if (this.changedDateTime.HasValue) + { + return this.changedDateTime.Value.ToString("s"); + } + return null; + } + set + { + } + } + public DateTime? changedDateTime { get; set; } + [DataMember(Name = "coverArt")] + [XmlAttribute(AttributeName = "coverArt")] + public string coverArt { get; set; } + [DataMember(Name = "allowedUser")] + [XmlElement(ElementName = "allowedUser")] + public string[] allowedUser { get; set; } + [DataMember(Name = "entry")] + [XmlElement(ElementName = "entry")] + public song[] entry { get; set; } + + public Playlist() + { + this.allowedUser = new string[0]; + this.entry = new song[0]; + } + } + + + + +} diff --git a/RoadieLibrary/Models/ThirdPartyApi/Subsonic/Podcasts.cs b/RoadieLibrary/Models/ThirdPartyApi/Subsonic/Podcasts.cs new file mode 100644 index 0000000..31d27cb --- /dev/null +++ b/RoadieLibrary/Models/ThirdPartyApi/Subsonic/Podcasts.cs @@ -0,0 +1,146 @@ +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.Serialization; +using System.ServiceModel; +using System.Text; +using System.Threading.Tasks; +using System.Xml.Serialization; + +namespace Roadie.Models.ThirdPartyApi.Subsonic +{ + [DataContract] + [XmlRoot(ElementName = "subsonic-response", Namespace = "http://subsonic.org/restapi")] + public class PodcastsXmlResponse : BaseResponse + { + [DataMember(Name = "podcasts")] + public Podcasts[] podcasts { get; set; } + } + + [DataContract] + public class PodcastsJsonResponseWrapper + { + [DataMember(Name = "subsonic-response")] + public PodcastsJsonResponse subsonicresponse { get; set; } + } + + [DataContract] + [XmlRoot(ElementName = "subsonic-response", Namespace = "http://subsonic.org/restapi")] + public class PodcastsJsonResponse : BaseResponse + { + [DataMember(Name = "podcasts")] + public Podcasts[] podcasts { get; set; } + } + + [DataContract] + public class Podcasts + { + [XmlElement(ElementName = "channel")] + public Channel[] channel { get; set; } + } + + [DataContract] + public class Channel + { + [XmlAttribute(AttributeName = "id")] + public string id { get; set; } + + [XmlAttribute(AttributeName = "url")] + public string url { get; set; } + + [XmlAttribute(AttributeName = "title")] + public string title { get; set; } + + [XmlAttribute(AttributeName = "description")] + public string description { get; set; } + + [XmlAttribute(AttributeName = "coverArt")] + public string coverArt { get; set; } + + [XmlAttribute(AttributeName = "originalImageUrl")] + public string originalImageUrl { get; set; } + + [XmlAttribute(AttributeName = "status")] + public string status { get; set; } + + [XmlElement(ElementName = "episode")] + public Episode[] episode { get; set; } + } + + [DataContract] + public class Episode + { + [XmlAttribute(AttributeName = "id")] + public string id { get; set; } + + [XmlAttribute(AttributeName = "streamId")] + public string streamId { get; set; } + + [XmlAttribute(AttributeName = "channelId")] + public string channelId { get; set; } + + [XmlAttribute(AttributeName = "title")] + public string title { get; set; } + + [XmlAttribute(AttributeName = "description")] + public string description { get; set; } + + [XmlAttribute(AttributeName = "publishDate")] + public string publishDate { get; set; } + + [XmlAttribute(AttributeName = "status")] + public string status { get; set; } + + [XmlAttribute(AttributeName = "parent")] + public string parent { get; set; } + + [XmlAttribute(AttributeName = "isDir")] + public string isDir { get; set; } + + [XmlAttribute(AttributeName = "album")] + public string album { get; set; } + + [XmlAttribute(AttributeName = "artist")] + public string artist { get; set; } + + [XmlAttribute(AttributeName = "year")] + public string year { get; set; } + + [XmlAttribute(AttributeName = "genre")] + public string genre { get; set; } + + [XmlAttribute(AttributeName = "coverArt")] + public string coverArt { get; set; } + + [XmlAttribute(AttributeName = "size")] + public string size { get; set; } + + [XmlAttribute(AttributeName = "contentType")] + public string contentType { get; set; } + + [XmlAttribute(AttributeName = "suffix")] + public string suffix { get; set; } + + [XmlAttribute(AttributeName = "duration")] + public string duration { get; set; } + + [XmlAttribute(AttributeName = "bitRate")] + public string bitRate { get; set; } + + [XmlAttribute(AttributeName = "isVideo")] + public string isVideo { get; set; } + + [XmlAttribute(AttributeName = "created")] + public string created { get; set; } + + [XmlAttribute(AttributeName = "artistId")] + public string artistId { get; set; } + + [XmlAttribute(AttributeName = "type")] + public string type { get; set; } + + [XmlAttribute(AttributeName = "path")] + public string path { get; set; } + } +} \ No newline at end of file diff --git a/RoadieLibrary/Models/ThirdPartyApi/Subsonic/RandomSongResponse.cs b/RoadieLibrary/Models/ThirdPartyApi/Subsonic/RandomSongResponse.cs new file mode 100644 index 0000000..ee513db --- /dev/null +++ b/RoadieLibrary/Models/ThirdPartyApi/Subsonic/RandomSongResponse.cs @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.Serialization; +using System.Text; +using System.Threading.Tasks; +using System.Xml.Serialization; + +namespace Roadie.Models.ThirdPartyApi.Subsonic +{ + [DataContract] + [XmlRoot(ElementName = "subsonic-response", Namespace = "http://subsonic.org/restapi")] + public class RandomSongsXmlResponse : BaseResponse + { + [DataMember(Name = "randomSongs")] + public randomSongs randomSongs { get; set; } + } + + [DataContract] + public class RandomSongsJsonResponseWrapper + { + [DataMember(Name = "subsonic-response")] + public RandomSongsJsonResponse subsonicresponse { get; set; } + } + + [DataContract] + [XmlRoot(ElementName = "subsonic-response", Namespace = "http://subsonic.org/restapi")] + public class RandomSongsJsonResponse : BaseResponse + { + [DataMember(Name = "randomSongs")] + public randomSongs randomSongs { get; set; } + } + + [DataContract] + public class randomSongs + { + [DataMember(Name = "song")] + public song[] song { get; set; } + } +} diff --git a/RoadieLibrary/Models/ThirdPartyApi/Subsonic/Search2Response.cs b/RoadieLibrary/Models/ThirdPartyApi/Subsonic/Search2Response.cs new file mode 100644 index 0000000..c40ae41 --- /dev/null +++ b/RoadieLibrary/Models/ThirdPartyApi/Subsonic/Search2Response.cs @@ -0,0 +1,70 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.Serialization; +using System.Text; +using System.Threading.Tasks; +using System.Xml.Serialization; + +namespace Roadie.Models.ThirdPartyApi.Subsonic +{ + [DataContract] + [XmlRoot(ElementName = "subsonic-response", Namespace = "http://subsonic.org/restapi")] + public class Search2XMLResponse : BaseResponse + { + [XmlElement(ElementName = "searchResult2")] + public searchResult2 searchResult2 { get; set; } + } + + + [DataContract] + public class Search2JsonResponseWrapper + { + [DataMember(Name = "subsonic-response")] + public searchResult2JsonResponse subsonicresponse { get; set; } + } + + [DataContract] + public class searchResult2JsonResponse : BaseResponse + { + [DataMember(Name = "searchResult2")] + public searchResult2 searchResult2 { get; set; } + } + + [DataContract] + [XmlRoot(ElementName = "subsonic-response", Namespace = "http://subsonic.org/restapi")] + public class Search3XMLResponse : BaseResponse + { + [XmlElement(ElementName = "searchResult3")] + public searchResult2 searchResult3 { get; set; } + } + + + [DataContract] + public class Search3JsonResponseWrapper + { + [DataMember(Name = "subsonic-response")] + public searchResult3JsonResponse subsonicresponse { get; set; } + } + + [DataContract] + public class searchResult3JsonResponse : BaseResponse + { + [DataMember(Name = "searchResult3")] + public searchResult2 searchResult3 { get; set; } + } + + [DataContract] + public class searchResult2 + { + [DataMember(Name = "artist")] + [XmlElement(ElementName = "artist")] + public artist[] artist { get; set; } + [DataMember(Name = "album")] + [XmlElement(ElementName = "album")] + public album[] album { get; set; } + [DataMember(Name = "song")] + [XmlElement(ElementName = "song")] + public song[] song { get; set; } + } +} diff --git a/RoadieLibrary/Models/ThirdPartyApi/Subsonic/Shortcut.cs b/RoadieLibrary/Models/ThirdPartyApi/Subsonic/Shortcut.cs new file mode 100644 index 0000000..d2192a7 --- /dev/null +++ b/RoadieLibrary/Models/ThirdPartyApi/Subsonic/Shortcut.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Xml.Serialization; + +namespace Roadie.Models.ThirdPartyApi.Subsonic +{ + [Serializable] + public class Shortcut + { + [XmlAttribute(AttributeName = "id")] + public string id { get; set; } + [XmlAttribute(AttributeName = "name")] + public string name { get; set; } + } +} diff --git a/RoadieLibrary/Models/ThirdPartyApi/Subsonic/Song.cs b/RoadieLibrary/Models/ThirdPartyApi/Subsonic/Song.cs new file mode 100644 index 0000000..f17370f --- /dev/null +++ b/RoadieLibrary/Models/ThirdPartyApi/Subsonic/Song.cs @@ -0,0 +1,204 @@ +using System; +using System.Runtime.Serialization; +using System.Xml.Serialization; + +namespace Roadie.Models.ThirdPartyApi.Subsonic +{ + [DataContract] + public class song + { + /// + /// Database ID + /// + [XmlIgnore] + public int ID { get; set; } + + [DataMember(Name = "id")] + [XmlAttribute(AttributeName = "id")] + public string id { get; set; } + + [DataMember(Name = "parent")] + [XmlAttribute(AttributeName = "parent")] + public string parent { get; set; } + + [DataMember(Name = "title")] + [XmlAttribute(AttributeName = "title")] + public string title { get; set; } + + [DataMember(Name = "album")] + [XmlAttribute(AttributeName = "album")] + public string album { get; set; } + + [DataMember(Name = "artist")] + [XmlAttribute(AttributeName = "artist")] + public string artist { get; set; } + + [DataMember(Name = "isDir")] + [XmlAttribute(AttributeName = "isDir")] + public bool isDir { get; set; } + + [DataMember(Name = "coverArt")] + [XmlAttribute(AttributeName = "coverArt")] + public string coverArt { get; set; } + + [DataMember(Name = "created")] + [XmlAttribute(AttributeName = "created")] + public string created + { + get + { + if (this.createdDateTime.HasValue) + { + return this.createdDateTime.Value.ToString("s"); + } + return null; + } + set + { + } + } + + [XmlIgnore] + public DateTime? createdDateTime { get; set; } + + [DataMember(Name = "starred")] + [XmlAttribute(AttributeName = "starred")] + public string starred + { + get + { + if (this.starredDateTime.HasValue) + { + return this.starredDateTime.Value.ToString("s"); + } + return null; + } + set + { + } + } + + public bool ShouldSerializestarred() + { + return this.starredDateTime.HasValue; + } + + [DataMember(Name = "duration")] + [XmlAttribute(AttributeName = "duration")] + public int duration + { + get + { + if (this.durationMilliseconds > 0) + { + var contentDurationTimeSpan = TimeSpan.FromMilliseconds((double) (this.durationMilliseconds ?? 0)); + return (int) contentDurationTimeSpan.TotalSeconds; + } + return 0; + } + set + { + } + } + + [XmlIgnore] + public int? durationMilliseconds { get; set; } + + [DataMember(Name = "bitRate")] + [XmlAttribute(AttributeName = "bitRate")] + public int bitRate { get; set; } + + [DataMember(Name = "track")] + [XmlAttribute(AttributeName = "track")] + public int track { get; set; } + + [DataMember(Name = "albumMediaNumber")] + [XmlIgnore] + public short? albumMediaNumber { get; set; } + + [DataMember(Name = "year")] + [XmlAttribute(AttributeName = "year")] + public int year + { + get + { + if (this.yearDateTime.HasValue) + { + return this.yearDateTime.Value.Year; + } + return 0; + } + set + { + } + } + + [XmlIgnore] + public DateTime? yearDateTime { get; set; } + + [DataMember(Name = "genre")] + [XmlAttribute(AttributeName = "genre")] + public string genre { get; set; } + + [DataMember(Name = "size")] + [XmlAttribute(AttributeName = "size")] + public int size { get; set; } + + [DataMember(Name = "suffix")] + [XmlAttribute(AttributeName = "suffix")] + public string suffix { get; set; } + + [DataMember(Name = "contentType")] + [XmlAttribute(AttributeName = "contentType")] + public string contentType { get; set; } + + [DataMember(Name = "path")] + [XmlAttribute(AttributeName = "path")] + public string path { get; set; } + + [DataMember(Name = "albumId")] + [XmlAttribute(AttributeName = "albumId")] + public string albumId { get; set; } + + [XmlIgnore] + public int albumID { get; set; } + + [DataMember(Name = "artistId")] + [XmlAttribute(AttributeName = "artistId")] + public string artistId { get; set; } + + [XmlIgnore] + public int artistID { get; set; } + + [DataMember(Name = "type")] + [XmlAttribute(AttributeName = "type")] + public string type { get; set; } + + [DataMember(Name = "playCount")] + [XmlAttribute(AttributeName = "playCount")] + public int playCount { get; set; } + + [DataMember(Name = "userRating")] + [XmlAttribute(AttributeName = "userRating")] + public short userRating { get; set; } + + [DataMember(Name = "averageRating")] + [XmlAttribute(AttributeName = "averageRating")] + public short averageRating { get; set; } + + [XmlIgnore] + public DateTime? starredDateTime { get; set; } + + [XmlIgnore] + public bool isValid { get; set; } + + public song() + { + this.type = "music"; + this.suffix = "mp3"; + this.bitRate = 320; + this.contentType = "audio/mpeg"; + this.isDir = false; + } + } +} \ No newline at end of file diff --git a/RoadieLibrary/Models/ThirdPartyApi/Subsonic/SongResponse.cs b/RoadieLibrary/Models/ThirdPartyApi/Subsonic/SongResponse.cs new file mode 100644 index 0000000..43a3170 --- /dev/null +++ b/RoadieLibrary/Models/ThirdPartyApi/Subsonic/SongResponse.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.Serialization; +using System.Text; +using System.Threading.Tasks; +using System.Xml.Serialization; + +namespace Roadie.Models.ThirdPartyApi.Subsonic +{ + [Serializable] + [XmlRoot(ElementName = "subsonic-response", Namespace = "http://subsonic.org/restapi")] + public class SongXmlResponse : BaseResponse + { + [XmlElement(ElementName = "song")] + public song song { get; set; } + } + + [DataContract] + public class SongJsonResponseWrapper + { + [DataMember(Name = "subsonic-response")] + public SongJsonResponse subsonicresponse { get; set; } + } + + + [DataContract] + public class SongJsonResponse : BaseResponse + { + [DataMember(Name = "song")] + public song song { get; set; } + } +} diff --git a/RoadieLibrary/Models/ThirdPartyApi/Subsonic/SongsByGenreResponse.cs b/RoadieLibrary/Models/ThirdPartyApi/Subsonic/SongsByGenreResponse.cs new file mode 100644 index 0000000..2b4f53a --- /dev/null +++ b/RoadieLibrary/Models/ThirdPartyApi/Subsonic/SongsByGenreResponse.cs @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.Serialization; +using System.Text; +using System.Threading.Tasks; +using System.Xml.Serialization; + +namespace Roadie.Models.ThirdPartyApi.Subsonic +{ + [Serializable] + [XmlRoot(ElementName = "subsonic-response", Namespace = "http://subsonic.org/restapi")] + public class SongsByGenreXmlResponse : BaseResponse + { + [XmlElement(ElementName = "songsByGenre")] + public SongsByGenreResponse songsByGenre { get; set; } + } + + [DataContract] + public class SongsByGenreJsonResponseWrapper + { + [DataMember(Name = "subsonic-response")] + public SongsByGenreJsonResponse subsonicresponse { get; set; } + } + + [DataContract] + public class SongsByGenreJsonResponse : BaseResponse + { + [DataMember(Name = "songsByGenre")] + [XmlElement(ElementName = "songsByGenre")] + public SongsByGenreResponse songsByGenre { get; set; } + } + + [DataContract] + public class SongsByGenreResponse : BaseResponse + { + [DataMember(Name = "song")] + [XmlElement(ElementName = "song")] + public song[] song { get; set; } + } + + + + +} diff --git a/RoadieLibrary/Models/ThirdPartyApi/Subsonic/Starred2Response.cs b/RoadieLibrary/Models/ThirdPartyApi/Subsonic/Starred2Response.cs new file mode 100644 index 0000000..2c02812 --- /dev/null +++ b/RoadieLibrary/Models/ThirdPartyApi/Subsonic/Starred2Response.cs @@ -0,0 +1,72 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.Serialization; +using System.Text; +using System.Threading.Tasks; +using System.Xml.Serialization; + +namespace Roadie.Models.ThirdPartyApi.Subsonic +{ + [DataContract] + [XmlRoot(ElementName = "subsonic-response", Namespace = "http://subsonic.org/restapi")] + public class StarredXMLResponse : BaseResponse + { + [XmlElement(ElementName = "starred")] + public starredResult starred { get; set; } + } + + [DataContract] + public class StarredJsonResponseWrapper + { + [DataMember(Name = "subsonic-response")] + public starredJsonResponse subsonicresponse { get; set; } + } + + [DataContract] + public class starredJsonResponse : BaseResponse + { + [DataMember(Name = "starred")] + public starredResult starred { get; set; } + } + + [DataContract] + [XmlRoot(ElementName = "subsonic-response", Namespace = "http://subsonic.org/restapi")] + public class Starred2XMLResponse : BaseResponse + { + [XmlElement(ElementName = "starred2")] + public starredResult starred2 { get; set; } + } + + [DataContract] + public class Starred2JsonResponseWrapper + { + [DataMember(Name = "subsonic-response")] + public starred2JsonResponse subsonicresponse { get; set; } + } + + [DataContract] + public class starred2JsonResponse : BaseResponse + { + [DataMember(Name = "starred2")] + public starredResult starred2 { get; set; } + } + + [DataContract] + public class starredResult + { + [DataMember(Name = "artist")] + [XmlElement(ElementName = "artist")] + public artist[] artist { get; set; } + [DataMember(Name = "album")] + [XmlElement(ElementName = "album")] + public album[] album { get; set; } + [DataMember(Name = "song")] + [XmlElement(ElementName = "song")] + public song[] song { get; set; } + } + + + + +} diff --git a/RoadieLibrary/Models/ThirdPartyApi/Subsonic/UserResponse.cs b/RoadieLibrary/Models/ThirdPartyApi/Subsonic/UserResponse.cs new file mode 100644 index 0000000..4e4a13b --- /dev/null +++ b/RoadieLibrary/Models/ThirdPartyApi/Subsonic/UserResponse.cs @@ -0,0 +1,159 @@ +using System; +using System.Runtime.Serialization; +using System.Xml.Serialization; + +namespace Roadie.Models.ThirdPartyApi.Subsonic +{ + [DataContract] + [XmlRoot(ElementName = "subsonic-response", Namespace = "http://subsonic.org/restapi")] + public class UserXMLResponse : BaseResponse + { + [XmlElement(ElementName = "user")] + public User user { get; set; } + } + + public class UserJsonResponseWrapper + { + [DataMember(Name = "subsonic-response")] + public UserJsonResponse subsonicresponse { get; set; } + } + + public class UserJsonResponse : BaseResponse + { + [DataMember(Name = "user")] + public User user { get; set; } + } + + public class User + { + /// + /// The name of the user + /// + [DataMember(Name = "username")] + [XmlAttribute(AttributeName = "username")] + public string username { get; set; } + + /// + /// The email address of the user. + /// + [DataMember(Name = "email")] + [XmlAttribute(AttributeName = "email")] + public string email { get; set; } + + [DataMember(Name = "scrobblingEnabled")] + [XmlAttribute(AttributeName = "scrobblingEnabled")] + public bool scrobblingEnabled { get; set; } + + /// + /// Whether the user is administrator. + /// + [DataMember(Name = "adminRole")] + [XmlAttribute(AttributeName = "adminRole")] + public bool adminRole { get; set; } + + /// + /// Whether the user is allowed to change personal settings and password. + /// + [DataMember(Name = "settingsRole")] + [XmlAttribute(AttributeName = "settingsRole")] + public bool settingsRole { get; set; } + + /// + /// Whether the user is allowed to download files. + /// + [DataMember(Name = "downloadRole")] + [XmlAttribute(AttributeName = "downloadRole")] + public bool downloadRole { get; set; } + + /// + /// Whether the user is allowed to upload files. + /// + [DataMember(Name = "uploadRole")] + [XmlAttribute(AttributeName = "uploadRole")] + public bool uploadRole { get; set; } + + /// + /// Whether the user is allowed to create and delete playlists. + /// + [DataMember(Name = "playlistRole")] + [XmlAttribute(AttributeName = "playlistRole")] + public bool playlistRole { get; set; } + + /// + /// Whether the user is allowed to change cover art and tags. + /// + [DataMember(Name = "coverArtRole")] + [XmlAttribute(AttributeName = "coverArtRole")] + public bool coverArtRole { get; set; } + + /// + /// Whether the user is allowed to create and edit comments and ratings. + /// + [DataMember(Name = "commentRole")] + [XmlAttribute(AttributeName = "commentRole")] + public bool commentRole { get; set; } + + /// + /// Whether the user is allowed to administrate Podcasts. + /// + [DataMember(Name = "podcastRole")] + [XmlAttribute(AttributeName = "podcastRole")] + public bool podcastRole { get; set; } + + /// + /// Whether the user is allowed to play files. + /// + [DataMember(Name = "streamRole")] + [XmlAttribute(AttributeName = "streamRole")] + public bool streamRole { get; set; } + + /// + /// Whether the user is allowed to play files in jukebox mode. + /// + [DataMember(Name = "jukeboxRole")] + [XmlAttribute(AttributeName = "jukeboxRole")] + public bool jukeboxRole { get; set; } + + /// + /// Whether the user is allowed to share files with anyone. + /// + [DataMember(Name = "shareRole")] + [XmlAttribute(AttributeName = "shareRole")] + public bool shareRole { get; set; } + + /// + /// Whether the user is allowed to start video conversions. + /// + [DataMember(Name = "videoConversionRole")] + [XmlAttribute(AttributeName = "videoConversionRole")] + public bool videoConversionRole { get; set; } + + [DataMember(Name = "avatarLastChanged")] + [XmlAttribute(AttributeName = "avatarLastChanged")] + public DateTime avatarLastChanged { get; set; } + + /// + /// IDs of the music folders the user is allowed access to. Include the parameter once for each folder. + /// + [DataMember(Name = "musicFolderId")] + [XmlAttribute(AttributeName = "musicFolderId")] + public int[] musicFolderId { get; set; } + + /// + /// The maximum bit rate (in Kbps) for the user. Audio streams of higher bit rates are automatically downsampled to this bit rate. Legal values: 0 (no limit), 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320. + /// + [DataMember(Name = "maxBitRate")] + [XmlAttribute(AttributeName = "maxBitRate")] + public int? maxBitRate { get; set; } + + public User() + { + this.settingsRole = true; + this.playlistRole = true; + this.commentRole = true; + this.streamRole = true; + this.shareRole = true; + } + + } +} \ No newline at end of file diff --git a/RoadieLibrary/Roadie.Library.csproj b/RoadieLibrary/Roadie.Library.csproj index 7a0f71a..559e718 100644 --- a/RoadieLibrary/Roadie.Library.csproj +++ b/RoadieLibrary/Roadie.Library.csproj @@ -6,6 +6,7 @@ + @@ -30,6 +31,8 @@ + + diff --git a/RoadieLibrary/Utility/EmailHelper.cs b/RoadieLibrary/Utility/EmailHelper.cs new file mode 100644 index 0000000..2e66589 --- /dev/null +++ b/RoadieLibrary/Utility/EmailHelper.cs @@ -0,0 +1,36 @@ +using Roadie.Library.Configuration; +using System.Net; +using System.Net.Mail; +using System.Net.Security; +using System.Security.Cryptography.X509Certificates; + +namespace Roadie.Library.Utility +{ + public static class EmailHelper + { + public static bool SendEmail(IRoadieSettings configuration, string emailAddress, string subject, string body) + { + using (MailMessage mail = new MailMessage(configuration.SmtpFromAddress, emailAddress)) + { + using (SmtpClient client = new SmtpClient()) + { + client.Port = configuration.SmtpPort; + client.EnableSsl = configuration.SmtpUseSSl; + client.DeliveryMethod = SmtpDeliveryMethod.Network; + client.UseDefaultCredentials = false; + client.Credentials = new NetworkCredential(configuration.SmtpUsername, configuration.SmtpPassword); + client.Host = configuration.SmtpHost; + mail.Subject = subject; + mail.IsBodyHtml = true; + mail.Body = body; + ServicePointManager.ServerCertificateValidationCallback = delegate (object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) + { + return true; + }; + client.Send(mail); + return true; + } + } + } + } +} diff --git a/RoadieLibrary/Utility/FtpHelper.cs b/RoadieLibrary/Utility/FtpHelper.cs new file mode 100644 index 0000000..cffc29a --- /dev/null +++ b/RoadieLibrary/Utility/FtpHelper.cs @@ -0,0 +1,47 @@ +using FluentFTP; +using System.Collections.Generic; +using System.IO; +using System.Net; + +namespace Roadie.Library.Utility +{ + public static class FtpHelper + { + public static int Download(string ftpHost, string ftpDirectory, NetworkCredential credentials, string localPath) + { + int result = 0; + using (FtpClient client = new FtpClient(ftpHost)) + { + client.Credentials = credentials; + client.Connect(); + + var foundFiles = new List(); + foreach (FtpListItem item in client.GetListing(ftpDirectory, FtpListOption.Recursive)) + { + switch (item.Type) + { + case FtpFileSystemObjectType.File: + foundFiles.Add(item.FullName); + break; + } + } + + foreach (var file in foundFiles) + { + var filenameWithFolder = file.Replace(ftpDirectory, string.Empty); + var fileFolder = Path.GetDirectoryName(filenameWithFolder); + var filename = Path.GetFileName(file); + + var localPathForFile = Path.Combine(localPath, fileFolder); + var localFilename = Path.Combine(localPathForFile, filename); + Directory.CreateDirectory(localPathForFile); + client.DownloadFile(localFilename, file); + result++; + } + + client.Disconnect(); + } + return result; + } + } +}