├── .gitattributes ├── .gitignore ├── LICENSE ├── OpenTidl.sln ├── OpenTidl ├── ClientConfiguration.cs ├── Enums │ ├── AlbumCoverSize.cs │ ├── AlbumFilter.cs │ ├── ArtistPictureSize.cs │ ├── ClientFilter.cs │ ├── ContributorRole.cs │ ├── LoginType.cs │ ├── PlaylistImageSize.cs │ ├── PlaylistType.cs │ ├── SoundQuality.cs │ ├── StreamResponseType.cs │ ├── StreamSource.cs │ ├── SubscriptionType.cs │ ├── UserGender.cs │ ├── VideoImageSize.cs │ └── VideoQuality.cs ├── HelperExtensions.cs ├── LICENSE.txt ├── Methods │ ├── OpenTidlLoginMethods.cs │ ├── OpenTidlLoginMethodsSync.cs │ ├── OpenTidlPublicMethods.cs │ ├── OpenTidlPublicMethodsSync.cs │ ├── OpenTidlSession.cs │ ├── OpenTidlSessionSync.cs │ └── OpenTidlStreamMethods.cs ├── Models │ ├── AlbumModel.cs │ ├── AlbumReviewModel.cs │ ├── ApplicationModel.cs │ ├── ApplicationTypeModel.cs │ ├── ArtistBiographyModel.cs │ ├── ArtistModel.cs │ ├── Base │ │ ├── ErrorModel.cs │ │ ├── JsonList.cs │ │ ├── JsonListItem.cs │ │ ├── ModelArray.cs │ │ ├── ModelBase.cs │ │ ├── SearchType.cs │ │ └── WebStreamModel.cs │ ├── ClientModel.cs │ ├── ContributorModel.cs │ ├── CountryModel.cs │ ├── CreatorModel.cs │ ├── EmptyModel.cs │ ├── LinkModel.cs │ ├── LoginModel.cs │ ├── PlaylistModel.cs │ ├── RecoverPasswordResponseModel.cs │ ├── SearchResultModel.cs │ ├── SessionModel.cs │ ├── StreamUrlModel.cs │ ├── SubscriptionModel.cs │ ├── TrackModel.cs │ ├── UserModel.cs │ ├── UserSubscriptionModel.cs │ ├── VideoModel.cs │ └── VideoStreamUrlModel.cs ├── OpenTidl.csproj ├── OpenTidl.nuspec ├── OpenTidlClient.cs ├── Properties │ └── AssemblyInfo.cs └── Transport │ ├── OpenTidlException.cs │ ├── RestClient.cs │ ├── RestResponse.cs │ └── RestUtility.cs └── README.md /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.sln.docstates 8 | 9 | # Build results 10 | [Dd]ebug/ 11 | [Dd]ebugPublic/ 12 | [Rr]elease/ 13 | x64/ 14 | build/ 15 | bld/ 16 | [Bb]in/ 17 | [Oo]bj/ 18 | 19 | # Roslyn cache directories 20 | *.ide/ 21 | 22 | # MSTest test Results 23 | [Tt]est[Rr]esult*/ 24 | [Bb]uild[Ll]og.* 25 | 26 | #NUNIT 27 | *.VisualState.xml 28 | TestResult.xml 29 | 30 | # Build Results of an ATL Project 31 | [Dd]ebugPS/ 32 | [Rr]eleasePS/ 33 | dlldata.c 34 | 35 | *_i.c 36 | *_p.c 37 | *_i.h 38 | *.ilk 39 | *.meta 40 | *.obj 41 | *.pch 42 | *.pdb 43 | *.pgc 44 | *.pgd 45 | *.rsp 46 | *.sbr 47 | *.tlb 48 | *.tli 49 | *.tlh 50 | *.tmp 51 | *.tmp_proj 52 | *.log 53 | *.vspscc 54 | *.vssscc 55 | .builds 56 | *.pidb 57 | *.svclog 58 | *.scc 59 | 60 | # Chutzpah Test files 61 | _Chutzpah* 62 | 63 | # Visual C++ cache files 64 | ipch/ 65 | *.aps 66 | *.ncb 67 | *.opensdf 68 | *.sdf 69 | *.cachefile 70 | 71 | # Visual Studio profiler 72 | *.psess 73 | *.vsp 74 | *.vspx 75 | 76 | # TFS 2012 Local Workspace 77 | $tf/ 78 | 79 | # Guidance Automation Toolkit 80 | *.gpState 81 | 82 | # ReSharper is a .NET coding add-in 83 | _ReSharper*/ 84 | *.[Rr]e[Ss]harper 85 | *.DotSettings.user 86 | 87 | # JustCode is a .NET coding addin-in 88 | .JustCode 89 | 90 | # TeamCity is a build add-in 91 | _TeamCity* 92 | 93 | # DotCover is a Code Coverage Tool 94 | *.dotCover 95 | 96 | # NCrunch 97 | _NCrunch_* 98 | .*crunch*.local.xml 99 | 100 | # MightyMoose 101 | *.mm.* 102 | AutoTest.Net/ 103 | 104 | # Web workbench (sass) 105 | .sass-cache/ 106 | 107 | # Installshield output folder 108 | [Ee]xpress/ 109 | 110 | # DocProject is a documentation generator add-in 111 | DocProject/buildhelp/ 112 | DocProject/Help/*.HxT 113 | DocProject/Help/*.HxC 114 | DocProject/Help/*.hhc 115 | DocProject/Help/*.hhk 116 | DocProject/Help/*.hhp 117 | DocProject/Help/Html2 118 | DocProject/Help/html 119 | 120 | # Click-Once directory 121 | publish/ 122 | 123 | # Publish Web Output 124 | *.[Pp]ublish.xml 125 | *.azurePubxml 126 | ## TODO: Comment the next line if you want to checkin your 127 | ## web deploy settings but do note that will include unencrypted 128 | ## passwords 129 | #*.pubxml 130 | 131 | # NuGet Packages Directory 132 | packages/* 133 | ## TODO: If the tool you use requires repositories.config 134 | ## uncomment the next line 135 | #!packages/repositories.config 136 | 137 | # Enable "build/" folder in the NuGet Packages folder since 138 | # NuGet packages use it for MSBuild targets. 139 | # This line needs to be after the ignore of the build folder 140 | # (and the packages folder if the line above has been uncommented) 141 | !packages/build/ 142 | *.nupkg 143 | 144 | # Windows Azure Build Output 145 | csx/ 146 | *.build.csdef 147 | 148 | # Windows Store app package directory 149 | AppPackages/ 150 | 151 | # Others 152 | sql/ 153 | *.Cache 154 | ClientBin/ 155 | [Ss]tyle[Cc]op.* 156 | ~$* 157 | *~ 158 | *.dbmdl 159 | *.dbproj.schemaview 160 | *.pfx 161 | *.publishsettings 162 | node_modules/ 163 | 164 | # RIA/Silverlight projects 165 | Generated_Code/ 166 | 167 | # Backup & report files from converting an old project file 168 | # to a newer Visual Studio version. Backup files are not needed, 169 | # because we have git ;-) 170 | _UpgradeReport_Files/ 171 | Backup*/ 172 | UpgradeLog*.XML 173 | UpgradeLog*.htm 174 | 175 | # SQL Server files 176 | *.mdf 177 | *.ldf 178 | 179 | # Business Intelligence projects 180 | *.rdl.data 181 | *.bim.layout 182 | *.bim_*.settings 183 | 184 | # Microsoft Fakes 185 | FakesAssemblies/ 186 | 187 | # LightSwitch generated files 188 | GeneratedArtifacts/ 189 | _Pvt_Extensions/ 190 | ModelManifest.xml -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU AFFERO GENERAL PUBLIC LICENSE 2 | Version 3, 19 November 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU Affero General Public License is a free, copyleft license for 11 | software and other kinds of works, specifically designed to ensure 12 | cooperation with the community in the case of network server software. 13 | 14 | The licenses for most software and other practical works are designed 15 | to take away your freedom to share and change the works. By contrast, 16 | our General Public Licenses are intended to guarantee your freedom to 17 | share and change all versions of a program--to make sure it remains free 18 | software for all its users. 19 | 20 | When we speak of free software, we are referring to freedom, not 21 | price. Our General Public Licenses are designed to make sure that you 22 | have the freedom to distribute copies of free software (and charge for 23 | them if you wish), that you receive source code or can get it if you 24 | want it, that you can change the software or use pieces of it in new 25 | free programs, and that you know you can do these things. 26 | 27 | Developers that use our General Public Licenses protect your rights 28 | with two steps: (1) assert copyright on the software, and (2) offer 29 | you this License which gives you legal permission to copy, distribute 30 | and/or modify the software. 31 | 32 | A secondary benefit of defending all users' freedom is that 33 | improvements made in alternate versions of the program, if they 34 | receive widespread use, become available for other developers to 35 | incorporate. Many developers of free software are heartened and 36 | encouraged by the resulting cooperation. However, in the case of 37 | software used on network servers, this result may fail to come about. 38 | The GNU General Public License permits making a modified version and 39 | letting the public access it on a server without ever releasing its 40 | source code to the public. 41 | 42 | The GNU Affero General Public License is designed specifically to 43 | ensure that, in such cases, the modified source code becomes available 44 | to the community. It requires the operator of a network server to 45 | provide the source code of the modified version running there to the 46 | users of that server. Therefore, public use of a modified version, on 47 | a publicly accessible server, gives the public access to the source 48 | code of the modified version. 49 | 50 | An older license, called the Affero General Public License and 51 | published by Affero, was designed to accomplish similar goals. This is 52 | a different license, not a version of the Affero GPL, but Affero has 53 | released a new version of the Affero GPL which permits relicensing under 54 | this license. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | TERMS AND CONDITIONS 60 | 61 | 0. Definitions. 62 | 63 | "This License" refers to version 3 of the GNU Affero General Public License. 64 | 65 | "Copyright" also means copyright-like laws that apply to other kinds of 66 | works, such as semiconductor masks. 67 | 68 | "The Program" refers to any copyrightable work licensed under this 69 | License. Each licensee is addressed as "you". "Licensees" and 70 | "recipients" may be individuals or organizations. 71 | 72 | To "modify" a work means to copy from or adapt all or part of the work 73 | in a fashion requiring copyright permission, other than the making of an 74 | exact copy. The resulting work is called a "modified version" of the 75 | earlier work or a work "based on" the earlier work. 76 | 77 | A "covered work" means either the unmodified Program or a work based 78 | on the Program. 79 | 80 | To "propagate" a work means to do anything with it that, without 81 | permission, would make you directly or secondarily liable for 82 | infringement under applicable copyright law, except executing it on a 83 | computer or modifying a private copy. Propagation includes copying, 84 | distribution (with or without modification), making available to the 85 | public, and in some countries other activities as well. 86 | 87 | To "convey" a work means any kind of propagation that enables other 88 | parties to make or receive copies. Mere interaction with a user through 89 | a computer network, with no transfer of a copy, is not conveying. 90 | 91 | An interactive user interface displays "Appropriate Legal Notices" 92 | to the extent that it includes a convenient and prominently visible 93 | feature that (1) displays an appropriate copyright notice, and (2) 94 | tells the user that there is no warranty for the work (except to the 95 | extent that warranties are provided), that licensees may convey the 96 | work under this License, and how to view a copy of this License. If 97 | the interface presents a list of user commands or options, such as a 98 | menu, a prominent item in the list meets this criterion. 99 | 100 | 1. Source Code. 101 | 102 | The "source code" for a work means the preferred form of the work 103 | for making modifications to it. "Object code" means any non-source 104 | form of a work. 105 | 106 | A "Standard Interface" means an interface that either is an official 107 | standard defined by a recognized standards body, or, in the case of 108 | interfaces specified for a particular programming language, one that 109 | is widely used among developers working in that language. 110 | 111 | The "System Libraries" of an executable work include anything, other 112 | than the work as a whole, that (a) is included in the normal form of 113 | packaging a Major Component, but which is not part of that Major 114 | Component, and (b) serves only to enable use of the work with that 115 | Major Component, or to implement a Standard Interface for which an 116 | implementation is available to the public in source code form. A 117 | "Major Component", in this context, means a major essential component 118 | (kernel, window system, and so on) of the specific operating system 119 | (if any) on which the executable work runs, or a compiler used to 120 | produce the work, or an object code interpreter used to run it. 121 | 122 | The "Corresponding Source" for a work in object code form means all 123 | the source code needed to generate, install, and (for an executable 124 | work) run the object code and to modify the work, including scripts to 125 | control those activities. However, it does not include the work's 126 | System Libraries, or general-purpose tools or generally available free 127 | programs which are used unmodified in performing those activities but 128 | which are not part of the work. For example, Corresponding Source 129 | includes interface definition files associated with source files for 130 | the work, and the source code for shared libraries and dynamically 131 | linked subprograms that the work is specifically designed to require, 132 | such as by intimate data communication or control flow between those 133 | subprograms and other parts of the work. 134 | 135 | The Corresponding Source need not include anything that users 136 | can regenerate automatically from other parts of the Corresponding 137 | Source. 138 | 139 | The Corresponding Source for a work in source code form is that 140 | same work. 141 | 142 | 2. Basic Permissions. 143 | 144 | All rights granted under this License are granted for the term of 145 | copyright on the Program, and are irrevocable provided the stated 146 | conditions are met. This License explicitly affirms your unlimited 147 | permission to run the unmodified Program. The output from running a 148 | covered work is covered by this License only if the output, given its 149 | content, constitutes a covered work. This License acknowledges your 150 | rights of fair use or other equivalent, as provided by copyright law. 151 | 152 | You may make, run and propagate covered works that you do not 153 | convey, without conditions so long as your license otherwise remains 154 | in force. You may convey covered works to others for the sole purpose 155 | of having them make modifications exclusively for you, or provide you 156 | with facilities for running those works, provided that you comply with 157 | the terms of this License in conveying all material for which you do 158 | not control copyright. Those thus making or running the covered works 159 | for you must do so exclusively on your behalf, under your direction 160 | and control, on terms that prohibit them from making any copies of 161 | your copyrighted material outside their relationship with you. 162 | 163 | Conveying under any other circumstances is permitted solely under 164 | the conditions stated below. Sublicensing is not allowed; section 10 165 | makes it unnecessary. 166 | 167 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 168 | 169 | No covered work shall be deemed part of an effective technological 170 | measure under any applicable law fulfilling obligations under article 171 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 172 | similar laws prohibiting or restricting circumvention of such 173 | measures. 174 | 175 | When you convey a covered work, you waive any legal power to forbid 176 | circumvention of technological measures to the extent such circumvention 177 | is effected by exercising rights under this License with respect to 178 | the covered work, and you disclaim any intention to limit operation or 179 | modification of the work as a means of enforcing, against the work's 180 | users, your or third parties' legal rights to forbid circumvention of 181 | technological measures. 182 | 183 | 4. Conveying Verbatim Copies. 184 | 185 | You may convey verbatim copies of the Program's source code as you 186 | receive it, in any medium, provided that you conspicuously and 187 | appropriately publish on each copy an appropriate copyright notice; 188 | keep intact all notices stating that this License and any 189 | non-permissive terms added in accord with section 7 apply to the code; 190 | keep intact all notices of the absence of any warranty; and give all 191 | recipients a copy of this License along with the Program. 192 | 193 | You may charge any price or no price for each copy that you convey, 194 | and you may offer support or warranty protection for a fee. 195 | 196 | 5. Conveying Modified Source Versions. 197 | 198 | You may convey a work based on the Program, or the modifications to 199 | produce it from the Program, in the form of source code under the 200 | terms of section 4, provided that you also meet all of these conditions: 201 | 202 | a) The work must carry prominent notices stating that you modified 203 | it, and giving a relevant date. 204 | 205 | b) The work must carry prominent notices stating that it is 206 | released under this License and any conditions added under section 207 | 7. This requirement modifies the requirement in section 4 to 208 | "keep intact all notices". 209 | 210 | c) You must license the entire work, as a whole, under this 211 | License to anyone who comes into possession of a copy. This 212 | License will therefore apply, along with any applicable section 7 213 | additional terms, to the whole of the work, and all its parts, 214 | regardless of how they are packaged. This License gives no 215 | permission to license the work in any other way, but it does not 216 | invalidate such permission if you have separately received it. 217 | 218 | d) If the work has interactive user interfaces, each must display 219 | Appropriate Legal Notices; however, if the Program has interactive 220 | interfaces that do not display Appropriate Legal Notices, your 221 | work need not make them do so. 222 | 223 | A compilation of a covered work with other separate and independent 224 | works, which are not by their nature extensions of the covered work, 225 | and which are not combined with it such as to form a larger program, 226 | in or on a volume of a storage or distribution medium, is called an 227 | "aggregate" if the compilation and its resulting copyright are not 228 | used to limit the access or legal rights of the compilation's users 229 | beyond what the individual works permit. Inclusion of a covered work 230 | in an aggregate does not cause this License to apply to the other 231 | parts of the aggregate. 232 | 233 | 6. Conveying Non-Source Forms. 234 | 235 | You may convey a covered work in object code form under the terms 236 | of sections 4 and 5, provided that you also convey the 237 | machine-readable Corresponding Source under the terms of this License, 238 | in one of these ways: 239 | 240 | a) Convey the object code in, or embodied in, a physical product 241 | (including a physical distribution medium), accompanied by the 242 | Corresponding Source fixed on a durable physical medium 243 | customarily used for software interchange. 244 | 245 | b) Convey the object code in, or embodied in, a physical product 246 | (including a physical distribution medium), accompanied by a 247 | written offer, valid for at least three years and valid for as 248 | long as you offer spare parts or customer support for that product 249 | model, to give anyone who possesses the object code either (1) a 250 | copy of the Corresponding Source for all the software in the 251 | product that is covered by this License, on a durable physical 252 | medium customarily used for software interchange, for a price no 253 | more than your reasonable cost of physically performing this 254 | conveying of source, or (2) access to copy the 255 | Corresponding Source from a network server at no charge. 256 | 257 | c) Convey individual copies of the object code with a copy of the 258 | written offer to provide the Corresponding Source. This 259 | alternative is allowed only occasionally and noncommercially, and 260 | only if you received the object code with such an offer, in accord 261 | with subsection 6b. 262 | 263 | d) Convey the object code by offering access from a designated 264 | place (gratis or for a charge), and offer equivalent access to the 265 | Corresponding Source in the same way through the same place at no 266 | further charge. You need not require recipients to copy the 267 | Corresponding Source along with the object code. If the place to 268 | copy the object code is a network server, the Corresponding Source 269 | may be on a different server (operated by you or a third party) 270 | that supports equivalent copying facilities, provided you maintain 271 | clear directions next to the object code saying where to find the 272 | Corresponding Source. Regardless of what server hosts the 273 | Corresponding Source, you remain obligated to ensure that it is 274 | available for as long as needed to satisfy these requirements. 275 | 276 | e) Convey the object code using peer-to-peer transmission, provided 277 | you inform other peers where the object code and Corresponding 278 | Source of the work are being offered to the general public at no 279 | charge under subsection 6d. 280 | 281 | A separable portion of the object code, whose source code is excluded 282 | from the Corresponding Source as a System Library, need not be 283 | included in conveying the object code work. 284 | 285 | A "User Product" is either (1) a "consumer product", which means any 286 | tangible personal property which is normally used for personal, family, 287 | or household purposes, or (2) anything designed or sold for incorporation 288 | into a dwelling. In determining whether a product is a consumer product, 289 | doubtful cases shall be resolved in favor of coverage. For a particular 290 | product received by a particular user, "normally used" refers to a 291 | typical or common use of that class of product, regardless of the status 292 | of the particular user or of the way in which the particular user 293 | actually uses, or expects or is expected to use, the product. A product 294 | is a consumer product regardless of whether the product has substantial 295 | commercial, industrial or non-consumer uses, unless such uses represent 296 | the only significant mode of use of the product. 297 | 298 | "Installation Information" for a User Product means any methods, 299 | procedures, authorization keys, or other information required to install 300 | and execute modified versions of a covered work in that User Product from 301 | a modified version of its Corresponding Source. The information must 302 | suffice to ensure that the continued functioning of the modified object 303 | code is in no case prevented or interfered with solely because 304 | modification has been made. 305 | 306 | If you convey an object code work under this section in, or with, or 307 | specifically for use in, a User Product, and the conveying occurs as 308 | part of a transaction in which the right of possession and use of the 309 | User Product is transferred to the recipient in perpetuity or for a 310 | fixed term (regardless of how the transaction is characterized), the 311 | Corresponding Source conveyed under this section must be accompanied 312 | by the Installation Information. But this requirement does not apply 313 | if neither you nor any third party retains the ability to install 314 | modified object code on the User Product (for example, the work has 315 | been installed in ROM). 316 | 317 | The requirement to provide Installation Information does not include a 318 | requirement to continue to provide support service, warranty, or updates 319 | for a work that has been modified or installed by the recipient, or for 320 | the User Product in which it has been modified or installed. Access to a 321 | network may be denied when the modification itself materially and 322 | adversely affects the operation of the network or violates the rules and 323 | protocols for communication across the network. 324 | 325 | Corresponding Source conveyed, and Installation Information provided, 326 | in accord with this section must be in a format that is publicly 327 | documented (and with an implementation available to the public in 328 | source code form), and must require no special password or key for 329 | unpacking, reading or copying. 330 | 331 | 7. Additional Terms. 332 | 333 | "Additional permissions" are terms that supplement the terms of this 334 | License by making exceptions from one or more of its conditions. 335 | Additional permissions that are applicable to the entire Program shall 336 | be treated as though they were included in this License, to the extent 337 | that they are valid under applicable law. If additional permissions 338 | apply only to part of the Program, that part may be used separately 339 | under those permissions, but the entire Program remains governed by 340 | this License without regard to the additional permissions. 341 | 342 | When you convey a copy of a covered work, you may at your option 343 | remove any additional permissions from that copy, or from any part of 344 | it. (Additional permissions may be written to require their own 345 | removal in certain cases when you modify the work.) You may place 346 | additional permissions on material, added by you to a covered work, 347 | for which you have or can give appropriate copyright permission. 348 | 349 | Notwithstanding any other provision of this License, for material you 350 | add to a covered work, you may (if authorized by the copyright holders of 351 | that material) supplement the terms of this License with terms: 352 | 353 | a) Disclaiming warranty or limiting liability differently from the 354 | terms of sections 15 and 16 of this License; or 355 | 356 | b) Requiring preservation of specified reasonable legal notices or 357 | author attributions in that material or in the Appropriate Legal 358 | Notices displayed by works containing it; or 359 | 360 | c) Prohibiting misrepresentation of the origin of that material, or 361 | requiring that modified versions of such material be marked in 362 | reasonable ways as different from the original version; or 363 | 364 | d) Limiting the use for publicity purposes of names of licensors or 365 | authors of the material; or 366 | 367 | e) Declining to grant rights under trademark law for use of some 368 | trade names, trademarks, or service marks; or 369 | 370 | f) Requiring indemnification of licensors and authors of that 371 | material by anyone who conveys the material (or modified versions of 372 | it) with contractual assumptions of liability to the recipient, for 373 | any liability that these contractual assumptions directly impose on 374 | those licensors and authors. 375 | 376 | All other non-permissive additional terms are considered "further 377 | restrictions" within the meaning of section 10. If the Program as you 378 | received it, or any part of it, contains a notice stating that it is 379 | governed by this License along with a term that is a further 380 | restriction, you may remove that term. If a license document contains 381 | a further restriction but permits relicensing or conveying under this 382 | License, you may add to a covered work material governed by the terms 383 | of that license document, provided that the further restriction does 384 | not survive such relicensing or conveying. 385 | 386 | If you add terms to a covered work in accord with this section, you 387 | must place, in the relevant source files, a statement of the 388 | additional terms that apply to those files, or a notice indicating 389 | where to find the applicable terms. 390 | 391 | Additional terms, permissive or non-permissive, may be stated in the 392 | form of a separately written license, or stated as exceptions; 393 | the above requirements apply either way. 394 | 395 | 8. Termination. 396 | 397 | You may not propagate or modify a covered work except as expressly 398 | provided under this License. Any attempt otherwise to propagate or 399 | modify it is void, and will automatically terminate your rights under 400 | this License (including any patent licenses granted under the third 401 | paragraph of section 11). 402 | 403 | However, if you cease all violation of this License, then your 404 | license from a particular copyright holder is reinstated (a) 405 | provisionally, unless and until the copyright holder explicitly and 406 | finally terminates your license, and (b) permanently, if the copyright 407 | holder fails to notify you of the violation by some reasonable means 408 | prior to 60 days after the cessation. 409 | 410 | Moreover, your license from a particular copyright holder is 411 | reinstated permanently if the copyright holder notifies you of the 412 | violation by some reasonable means, this is the first time you have 413 | received notice of violation of this License (for any work) from that 414 | copyright holder, and you cure the violation prior to 30 days after 415 | your receipt of the notice. 416 | 417 | Termination of your rights under this section does not terminate the 418 | licenses of parties who have received copies or rights from you under 419 | this License. If your rights have been terminated and not permanently 420 | reinstated, you do not qualify to receive new licenses for the same 421 | material under section 10. 422 | 423 | 9. Acceptance Not Required for Having Copies. 424 | 425 | You are not required to accept this License in order to receive or 426 | run a copy of the Program. Ancillary propagation of a covered work 427 | occurring solely as a consequence of using peer-to-peer transmission 428 | to receive a copy likewise does not require acceptance. However, 429 | nothing other than this License grants you permission to propagate or 430 | modify any covered work. These actions infringe copyright if you do 431 | not accept this License. Therefore, by modifying or propagating a 432 | covered work, you indicate your acceptance of this License to do so. 433 | 434 | 10. Automatic Licensing of Downstream Recipients. 435 | 436 | Each time you convey a covered work, the recipient automatically 437 | receives a license from the original licensors, to run, modify and 438 | propagate that work, subject to this License. You are not responsible 439 | for enforcing compliance by third parties with this License. 440 | 441 | An "entity transaction" is a transaction transferring control of an 442 | organization, or substantially all assets of one, or subdividing an 443 | organization, or merging organizations. If propagation of a covered 444 | work results from an entity transaction, each party to that 445 | transaction who receives a copy of the work also receives whatever 446 | licenses to the work the party's predecessor in interest had or could 447 | give under the previous paragraph, plus a right to possession of the 448 | Corresponding Source of the work from the predecessor in interest, if 449 | the predecessor has it or can get it with reasonable efforts. 450 | 451 | You may not impose any further restrictions on the exercise of the 452 | rights granted or affirmed under this License. For example, you may 453 | not impose a license fee, royalty, or other charge for exercise of 454 | rights granted under this License, and you may not initiate litigation 455 | (including a cross-claim or counterclaim in a lawsuit) alleging that 456 | any patent claim is infringed by making, using, selling, offering for 457 | sale, or importing the Program or any portion of it. 458 | 459 | 11. Patents. 460 | 461 | A "contributor" is a copyright holder who authorizes use under this 462 | License of the Program or a work on which the Program is based. The 463 | work thus licensed is called the contributor's "contributor version". 464 | 465 | A contributor's "essential patent claims" are all patent claims 466 | owned or controlled by the contributor, whether already acquired or 467 | hereafter acquired, that would be infringed by some manner, permitted 468 | by this License, of making, using, or selling its contributor version, 469 | but do not include claims that would be infringed only as a 470 | consequence of further modification of the contributor version. For 471 | purposes of this definition, "control" includes the right to grant 472 | patent sublicenses in a manner consistent with the requirements of 473 | this License. 474 | 475 | Each contributor grants you a non-exclusive, worldwide, royalty-free 476 | patent license under the contributor's essential patent claims, to 477 | make, use, sell, offer for sale, import and otherwise run, modify and 478 | propagate the contents of its contributor version. 479 | 480 | In the following three paragraphs, a "patent license" is any express 481 | agreement or commitment, however denominated, not to enforce a patent 482 | (such as an express permission to practice a patent or covenant not to 483 | sue for patent infringement). To "grant" such a patent license to a 484 | party means to make such an agreement or commitment not to enforce a 485 | patent against the party. 486 | 487 | If you convey a covered work, knowingly relying on a patent license, 488 | and the Corresponding Source of the work is not available for anyone 489 | to copy, free of charge and under the terms of this License, through a 490 | publicly available network server or other readily accessible means, 491 | then you must either (1) cause the Corresponding Source to be so 492 | available, or (2) arrange to deprive yourself of the benefit of the 493 | patent license for this particular work, or (3) arrange, in a manner 494 | consistent with the requirements of this License, to extend the patent 495 | license to downstream recipients. "Knowingly relying" means you have 496 | actual knowledge that, but for the patent license, your conveying the 497 | covered work in a country, or your recipient's use of the covered work 498 | in a country, would infringe one or more identifiable patents in that 499 | country that you have reason to believe are valid. 500 | 501 | If, pursuant to or in connection with a single transaction or 502 | arrangement, you convey, or propagate by procuring conveyance of, a 503 | covered work, and grant a patent license to some of the parties 504 | receiving the covered work authorizing them to use, propagate, modify 505 | or convey a specific copy of the covered work, then the patent license 506 | you grant is automatically extended to all recipients of the covered 507 | work and works based on it. 508 | 509 | A patent license is "discriminatory" if it does not include within 510 | the scope of its coverage, prohibits the exercise of, or is 511 | conditioned on the non-exercise of one or more of the rights that are 512 | specifically granted under this License. You may not convey a covered 513 | work if you are a party to an arrangement with a third party that is 514 | in the business of distributing software, under which you make payment 515 | to the third party based on the extent of your activity of conveying 516 | the work, and under which the third party grants, to any of the 517 | parties who would receive the covered work from you, a discriminatory 518 | patent license (a) in connection with copies of the covered work 519 | conveyed by you (or copies made from those copies), or (b) primarily 520 | for and in connection with specific products or compilations that 521 | contain the covered work, unless you entered into that arrangement, 522 | or that patent license was granted, prior to 28 March 2007. 523 | 524 | Nothing in this License shall be construed as excluding or limiting 525 | any implied license or other defenses to infringement that may 526 | otherwise be available to you under applicable patent law. 527 | 528 | 12. No Surrender of Others' Freedom. 529 | 530 | If conditions are imposed on you (whether by court order, agreement or 531 | otherwise) that contradict the conditions of this License, they do not 532 | excuse you from the conditions of this License. If you cannot convey a 533 | covered work so as to satisfy simultaneously your obligations under this 534 | License and any other pertinent obligations, then as a consequence you may 535 | not convey it at all. For example, if you agree to terms that obligate you 536 | to collect a royalty for further conveying from those to whom you convey 537 | the Program, the only way you could satisfy both those terms and this 538 | License would be to refrain entirely from conveying the Program. 539 | 540 | 13. Remote Network Interaction; Use with the GNU General Public License. 541 | 542 | Notwithstanding any other provision of this License, if you modify the 543 | Program, your modified version must prominently offer all users 544 | interacting with it remotely through a computer network (if your version 545 | supports such interaction) an opportunity to receive the Corresponding 546 | Source of your version by providing access to the Corresponding Source 547 | from a network server at no charge, through some standard or customary 548 | means of facilitating copying of software. This Corresponding Source 549 | shall include the Corresponding Source for any work covered by version 3 550 | of the GNU General Public License that is incorporated pursuant to the 551 | following paragraph. 552 | 553 | Notwithstanding any other provision of this License, you have 554 | permission to link or combine any covered work with a work licensed 555 | under version 3 of the GNU General Public License into a single 556 | combined work, and to convey the resulting work. The terms of this 557 | License will continue to apply to the part which is the covered work, 558 | but the work with which it is combined will remain governed by version 559 | 3 of the GNU General Public License. 560 | 561 | 14. Revised Versions of this License. 562 | 563 | The Free Software Foundation may publish revised and/or new versions of 564 | the GNU Affero General Public License from time to time. Such new versions 565 | will be similar in spirit to the present version, but may differ in detail to 566 | address new problems or concerns. 567 | 568 | Each version is given a distinguishing version number. If the 569 | Program specifies that a certain numbered version of the GNU Affero General 570 | Public License "or any later version" applies to it, you have the 571 | option of following the terms and conditions either of that numbered 572 | version or of any later version published by the Free Software 573 | Foundation. If the Program does not specify a version number of the 574 | GNU Affero General Public License, you may choose any version ever published 575 | by the Free Software Foundation. 576 | 577 | If the Program specifies that a proxy can decide which future 578 | versions of the GNU Affero General Public License can be used, that proxy's 579 | public statement of acceptance of a version permanently authorizes you 580 | to choose that version for the Program. 581 | 582 | Later license versions may give you additional or different 583 | permissions. However, no additional obligations are imposed on any 584 | author or copyright holder as a result of your choosing to follow a 585 | later version. 586 | 587 | 15. Disclaimer of Warranty. 588 | 589 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 590 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 591 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 592 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 593 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 594 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 595 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 596 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 597 | 598 | 16. Limitation of Liability. 599 | 600 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 601 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 602 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 603 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 604 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 605 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 606 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 607 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 608 | SUCH DAMAGES. 609 | 610 | 17. Interpretation of Sections 15 and 16. 611 | 612 | If the disclaimer of warranty and limitation of liability provided 613 | above cannot be given local legal effect according to their terms, 614 | reviewing courts shall apply local law that most closely approximates 615 | an absolute waiver of all civil liability in connection with the 616 | Program, unless a warranty or assumption of liability accompanies a 617 | copy of the Program in return for a fee. 618 | 619 | END OF TERMS AND CONDITIONS 620 | 621 | How to Apply These Terms to Your New Programs 622 | 623 | If you develop a new program, and you want it to be of the greatest 624 | possible use to the public, the best way to achieve this is to make it 625 | free software which everyone can redistribute and change under these terms. 626 | 627 | To do so, attach the following notices to the program. It is safest 628 | to attach them to the start of each source file to most effectively 629 | state the exclusion of warranty; and each file should have at least 630 | the "copyright" line and a pointer to where the full notice is found. 631 | 632 | 633 | Copyright (C) 634 | 635 | This program is free software: you can redistribute it and/or modify 636 | it under the terms of the GNU Affero General Public License as published by 637 | the Free Software Foundation, either version 3 of the License, or 638 | (at your option) any later version. 639 | 640 | This program is distributed in the hope that it will be useful, 641 | but WITHOUT ANY WARRANTY; without even the implied warranty of 642 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 643 | GNU Affero General Public License for more details. 644 | 645 | You should have received a copy of the GNU Affero General Public License 646 | along with this program. If not, see . 647 | 648 | Also add information on how to contact you by electronic and paper mail. 649 | 650 | If your software can interact with users remotely through a computer 651 | network, you should also make sure that it provides a way for users to 652 | get its source. For example, if your program is a web application, its 653 | interface could display a "Source" link that leads users to an archive 654 | of the code. There are many ways you could offer source, and different 655 | solutions will be better for different programs; see section 13 for the 656 | specific requirements. 657 | 658 | You should also get your employer (if you work as a programmer) or school, 659 | if any, to sign a "copyright disclaimer" for the program, if necessary. 660 | For more information on this, and how to apply and follow the GNU AGPL, see 661 | . 662 | -------------------------------------------------------------------------------- /OpenTidl.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | VisualStudioVersion = 12.0.31101.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenTidl", "OpenTidl\OpenTidl.csproj", "{3796564B-3A91-4AEE-B859-E7E6BCF1521D}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {3796564B-3A91-4AEE-B859-E7E6BCF1521D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {3796564B-3A91-4AEE-B859-E7E6BCF1521D}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {3796564B-3A91-4AEE-B859-E7E6BCF1521D}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {3796564B-3A91-4AEE-B859-E7E6BCF1521D}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | EndGlobal 23 | -------------------------------------------------------------------------------- /OpenTidl/ClientConfiguration.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2015 Jack Fagner 3 | 4 | This file is part of OpenTidl. 5 | 6 | OpenTidl is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU Affero General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | OpenTidl is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU Affero General Public License for more details. 15 | 16 | You should have received a copy of the GNU Affero General Public License 17 | along with OpenTidl. If not, see . 18 | */ 19 | using System; 20 | using System.Collections.Generic; 21 | using System.Linq; 22 | using System.Text; 23 | using System.Threading.Tasks; 24 | using System.Net.NetworkInformation; 25 | 26 | namespace OpenTidl 27 | { 28 | public class ClientConfiguration 29 | { 30 | #region static properties 31 | 32 | private static Lazy _defaultSettings = new Lazy(() => 33 | new ClientConfiguration("https://api.tidalhifi.com/v1", "TIDAL_ANDROID/680 okhttp/3.3.1", 34 | "pl4Vc0hemlAXD0mN", DefaultClientUniqueKey, "1.12.2", "US")); 35 | 36 | public static ClientConfiguration Default 37 | { 38 | get { return _defaultSettings.Value; } 39 | } 40 | 41 | #endregion 42 | 43 | 44 | #region properties 45 | 46 | public String ApiEndpoint { get; private set; } 47 | public String UserAgent { get; private set; } 48 | public String Token { get; private set; } 49 | public String ClientUniqueKey { get; private set; } 50 | public String ClientVersion { get; private set; } 51 | public String DefaultCountryCode { get; private set; } 52 | 53 | #endregion 54 | 55 | 56 | #region methods 57 | 58 | private static String DefaultClientUniqueKey 59 | { 60 | get 61 | { 62 | var macAddress = NetworkInterface.GetAllNetworkInterfaces().Where(i => 63 | i.OperationalStatus == OperationalStatus.Up && i.NetworkInterfaceType != NetworkInterfaceType.Loopback).OrderByDescending(i => 64 | i.Speed).Select(i => i.GetPhysicalAddress().GetAddressBytes()).FirstOrDefault(); 65 | if (macAddress == null) 66 | return "123456789012345"; 67 | return String.Join("", macAddress.Skip(1).Select(b => b.ToString("000"))); 68 | } 69 | } 70 | 71 | #endregion 72 | 73 | 74 | #region construction 75 | 76 | public ClientConfiguration(String apiEndpoint, String userAgent, String token, String clientUniqueKey, String clientVersion, String defaultCountryCode) 77 | { 78 | this.ApiEndpoint = apiEndpoint; 79 | this.UserAgent = userAgent; 80 | this.Token = token; 81 | this.ClientUniqueKey = clientUniqueKey; 82 | this.ClientVersion = clientVersion; 83 | this.DefaultCountryCode = defaultCountryCode; 84 | } 85 | 86 | #endregion 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /OpenTidl/Enums/AlbumCoverSize.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace OpenTidl.Enums 8 | { 9 | public enum AlbumCoverSize 10 | { 11 | Size_80x80, 12 | Size_160x160, 13 | Size_320x320, 14 | Size_640x640, 15 | Size_750x750, 16 | Size_1080x1080, 17 | Size_1280x1280 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /OpenTidl/Enums/AlbumFilter.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2015 Jack Fagner 3 | 4 | This file is part of OpenTidl. 5 | 6 | OpenTidl is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU Affero General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | OpenTidl is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU Affero General Public License for more details. 15 | 16 | You should have received a copy of the GNU Affero General Public License 17 | along with OpenTidl. If not, see . 18 | */ 19 | using System; 20 | 21 | namespace OpenTidl.Enums 22 | { 23 | public enum AlbumFilter 24 | { 25 | ALBUMS, 26 | COMPILATIONS, 27 | EPSANDSINGLES 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /OpenTidl/Enums/ArtistPictureSize.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace OpenTidl.Enums 8 | { 9 | public enum ArtistPictureSize 10 | { 11 | Size_160x107, 12 | Size_320x214, 13 | Size_640x428, 14 | Size_750x500, 15 | Size_1080x720, 16 | Square_160x160, 17 | Square_320x320, 18 | Square_480x480, 19 | Square_750x750 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /OpenTidl/Enums/ClientFilter.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2015 Jack Fagner 3 | 4 | This file is part of OpenTidl. 5 | 6 | OpenTidl is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU Affero General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | OpenTidl is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU Affero General Public License for more details. 15 | 16 | You should have received a copy of the GNU Affero General Public License 17 | along with OpenTidl. If not, see . 18 | */ 19 | using System; 20 | 21 | namespace OpenTidl.Enums 22 | { 23 | public enum ClientFilter 24 | { 25 | ALL, 26 | AUTHORIZED, 27 | HAS_OFFLINE_CONTENT 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /OpenTidl/Enums/ContributorRole.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2015 Jack Fagner 3 | 4 | This file is part of OpenTidl. 5 | 6 | OpenTidl is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU Affero General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | OpenTidl is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU Affero General Public License for more details. 15 | 16 | You should have received a copy of the GNU Affero General Public License 17 | along with OpenTidl. If not, see . 18 | */ 19 | using System; 20 | 21 | namespace OpenTidl.Enums 22 | { 23 | public enum ContributorRole 24 | { 25 | COMPOSER = 0, 26 | LYRICIST = 1, 27 | PERFORMER = 2, 28 | FEATURING = 3, 29 | PRODUCER = 4, 30 | REMIXER = 5, 31 | ENSEMBLE_ORCHESTRA = 6, 32 | CHOIR = 7, 33 | CONDUCTOR = 8, 34 | MIX_ENGINEER = 9, 35 | MASTERING_ENGINEER = 10 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /OpenTidl/Enums/LoginType.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2015 Jack Fagner 3 | 4 | This file is part of OpenTidl. 5 | 6 | OpenTidl is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU Affero General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | OpenTidl is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU Affero General Public License for more details. 15 | 16 | You should have received a copy of the GNU Affero General Public License 17 | along with OpenTidl. If not, see . 18 | */ 19 | using System; 20 | 21 | namespace OpenTidl.Enums 22 | { 23 | public enum LoginType 24 | { 25 | Unknown = 0, 26 | Facebook, 27 | Spid, 28 | Token, 29 | Twitter, 30 | Username 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /OpenTidl/Enums/PlaylistImageSize.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace OpenTidl.Enums 8 | { 9 | public enum PlaylistImageSize 10 | { 11 | Size_160x107, 12 | Size_320x214, 13 | Size_480x320, 14 | Size_640x428, 15 | Size_750x500, 16 | Size_1080x720 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /OpenTidl/Enums/PlaylistType.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2015 Jack Fagner 3 | 4 | This file is part of OpenTidl. 5 | 6 | OpenTidl is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU Affero General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | OpenTidl is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU Affero General Public License for more details. 15 | 16 | You should have received a copy of the GNU Affero General Public License 17 | along with OpenTidl. If not, see . 18 | */ 19 | using System; 20 | 21 | namespace OpenTidl.Enums 22 | { 23 | public enum PlaylistType 24 | { 25 | EDITORIAL, 26 | PRIVATE, 27 | USER 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /OpenTidl/Enums/SoundQuality.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2015 Jack Fagner 3 | 4 | This file is part of OpenTidl. 5 | 6 | OpenTidl is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU Affero General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | OpenTidl is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU Affero General Public License for more details. 15 | 16 | You should have received a copy of the GNU Affero General Public License 17 | along with OpenTidl. If not, see . 18 | */ 19 | using System; 20 | 21 | namespace OpenTidl.Enums 22 | { 23 | public enum SoundQuality 24 | { 25 | LOW = 0, 26 | HIGH = 1, 27 | LOSSLESS = 2, 28 | LOSSLESS_HD = 3 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /OpenTidl/Enums/StreamResponseType.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2015 Jack Fagner 3 | 4 | This file is part of OpenTidl. 5 | 6 | OpenTidl is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU Affero General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | OpenTidl is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU Affero General Public License for more details. 15 | 16 | You should have received a copy of the GNU Affero General Public License 17 | along with OpenTidl. If not, see . 18 | */ 19 | using System; 20 | 21 | namespace OpenTidl.Enums 22 | { 23 | public enum StreamResponseType 24 | { 25 | OK = 0, 26 | INVALID_SESSION = 1, 27 | BAD_NETWORK = 2, 28 | NO_NETWORK = 3, 29 | OFFLINE_NOT_AVAILABLE = 4, 30 | STREAMING_NOT_ALLOWED = 5, 31 | STREAMING_PRIVILEGES_LOST = 6, 32 | STREAMING_TRACK_NOT_READY = 7, 33 | API_ERROR = 8 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /OpenTidl/Enums/StreamSource.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2015 Jack Fagner 3 | 4 | This file is part of OpenTidl. 5 | 6 | OpenTidl is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU Affero General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | OpenTidl is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU Affero General Public License for more details. 15 | 16 | You should have received a copy of the GNU Affero General Public License 17 | along with OpenTidl. If not, see . 18 | */ 19 | using System; 20 | 21 | namespace OpenTidl.Enums 22 | { 23 | public enum StreamSource 24 | { 25 | ONLINE = 0, 26 | OFFLINE = 1, 27 | CACHE = 2 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /OpenTidl/Enums/SubscriptionType.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2015 Jack Fagner 3 | 4 | This file is part of OpenTidl. 5 | 6 | OpenTidl is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU Affero General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | OpenTidl is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU Affero General Public License for more details. 15 | 16 | You should have received a copy of the GNU Affero General Public License 17 | along with OpenTidl. If not, see . 18 | */ 19 | using System; 20 | 21 | namespace OpenTidl.Enums 22 | { 23 | public enum SubscriptionType 24 | { 25 | BASIC, 26 | FREE, 27 | HIFI, 28 | PREMIUM, 29 | PROFESSIONAL 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /OpenTidl/Enums/UserGender.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2015 Jack Fagner 3 | 4 | This file is part of OpenTidl. 5 | 6 | OpenTidl is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU Affero General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | OpenTidl is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU Affero General Public License for more details. 15 | 16 | You should have received a copy of the GNU Affero General Public License 17 | along with OpenTidl. If not, see . 18 | */ 19 | using System; 20 | 21 | namespace OpenTidl.Enums 22 | { 23 | public enum UserGender 24 | { 25 | NotSpecified, 26 | Male, 27 | Female 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /OpenTidl/Enums/VideoImageSize.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace OpenTidl.Enums 8 | { 9 | public enum VideoImageSize 10 | { 11 | Size_160x107, 12 | Size_320x214, 13 | Size_480x320, 14 | Size_640x428, 15 | Size_750x500, 16 | Size_1080x720 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /OpenTidl/Enums/VideoQuality.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2015 Jack Fagner 3 | 4 | This file is part of OpenTidl. 5 | 6 | OpenTidl is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU Affero General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | OpenTidl is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU Affero General Public License for more details. 15 | 16 | You should have received a copy of the GNU Affero General Public License 17 | along with OpenTidl. If not, see . 18 | */ 19 | using System; 20 | 21 | namespace OpenTidl.Enums 22 | { 23 | public enum VideoQuality 24 | { 25 | MP4_240P = 0, 26 | MP4_360P = 1, 27 | MP4_480P = 2, 28 | MP4_720P = 3, 29 | MP4_1080P = 4 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /OpenTidl/HelperExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.IO; 7 | 8 | namespace OpenTidl 9 | { 10 | public static class HelperExtensions 11 | { 12 | public static Byte[] ToArray(this Stream stream, Int32? timeout = null) 13 | { 14 | using (var ms = new MemoryStream()) 15 | { 16 | var task = stream.CopyToAsync(ms); 17 | if (timeout.HasValue && !task.Wait(timeout.Value)) 18 | throw new TimeoutException(); 19 | else if (!timeout.HasValue) 20 | task.Wait(); 21 | return ms.ToArray(); 22 | } 23 | } 24 | 25 | /// 26 | /// Warning: causes deadlocks when used on UI thread 27 | /// 28 | private static T Sync(this Task task, Int32? timeout = null) 29 | { 30 | if (timeout.HasValue && !task.Wait(timeout.Value)) 31 | throw new TimeoutException(); 32 | /*if (!timeout.HasValue) 33 | task.Wait();*/ 34 | return task.Result; 35 | } 36 | 37 | public static T Sync(this Func> task, Int32? timeout = null) 38 | { 39 | return Task.Run(task).Sync(timeout); 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /OpenTidl/Methods/OpenTidlLoginMethods.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2015 Jack Fagner 3 | 4 | This file is part of OpenTidl. 5 | 6 | OpenTidl is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU Affero General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | OpenTidl is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU Affero General Public License for more details. 15 | 16 | You should have received a copy of the GNU Affero General Public License 17 | along with OpenTidl. If not, see . 18 | */ 19 | using System; 20 | using System.Collections.Generic; 21 | using System.Linq; 22 | using System.Text; 23 | using System.Threading.Tasks; 24 | using OpenTidl.Models; 25 | using OpenTidl.Models.Base; 26 | using OpenTidl.Transport; 27 | using OpenTidl.Methods; 28 | using OpenTidl.Enums; 29 | 30 | namespace OpenTidl 31 | { 32 | public partial class OpenTidlClient 33 | { 34 | #region login methods 35 | 36 | public async Task LoginWithFacebook(String accessToken) 37 | { 38 | return new OpenTidlSession(this, HandleLoginResponse(await RestClient.Process("/login/facebook", null, new 39 | { 40 | accessToken = accessToken, 41 | token = Configuration.Token, 42 | clientUniqueKey = Configuration.ClientUniqueKey, 43 | clientVersion = Configuration.ClientVersion 44 | }, "POST"), LoginType.Facebook)); 45 | } 46 | 47 | /*[Obsolete] 48 | public async Task LoginWithSpidToken(String accessToken, String spidUserId) 49 | { 50 | return new OpenTidlSession(this, HandleLoginResponse(await RestClient.Process("/login/spid/token", null, new 51 | { 52 | accessToken = accessToken, 53 | spidUserId = spidUserId, 54 | token = Configuration.Token, 55 | clientUniqueKey = Configuration.ClientUniqueKey, 56 | clientVersion = Configuration.ClientVersion 57 | }, "POST"), LoginType.Spid)); 58 | }*/ 59 | 60 | public async Task LoginWithToken(String authenticationToken) 61 | { 62 | return new OpenTidlSession(this, HandleLoginResponse(await RestClient.Process("/login/token", null, new 63 | { 64 | authenticationToken = authenticationToken, 65 | token = Configuration.Token, 66 | clientUniqueKey = Configuration.ClientUniqueKey, 67 | clientVersion = Configuration.ClientVersion 68 | }, "POST"), LoginType.Token)); 69 | } 70 | 71 | public async Task LoginWithTwitter(String accessToken, String accessTokenSecret) 72 | { 73 | return new OpenTidlSession(this, HandleLoginResponse(await RestClient.Process("/login/twitter", null, new 74 | { 75 | accessToken = accessToken, 76 | accessTokenSecret = accessTokenSecret, 77 | token = Configuration.Token, 78 | clientUniqueKey = Configuration.ClientUniqueKey, 79 | clientVersion = Configuration.ClientVersion 80 | }, "POST"), LoginType.Twitter)); 81 | } 82 | 83 | public async Task LoginWithUsername(String username, String password) 84 | { 85 | return new OpenTidlSession(this, HandleLoginResponse(await RestClient.Process("/login/username", null, new 86 | { 87 | username = username, 88 | password = password, 89 | token = Configuration.Token, 90 | clientUniqueKey = Configuration.ClientUniqueKey, 91 | clientVersion = Configuration.ClientVersion 92 | }, "POST"), LoginType.Username)); 93 | } 94 | 95 | #endregion 96 | 97 | 98 | #region session methods 99 | 100 | public async Task RestoreSession(String sessionId) 101 | { 102 | return new OpenTidlSession(this, LoginModel.FromSession(HandleSessionResponse(await RestClient.Process( 103 | RestUtility.FormatUrl("/sessions/{sessionId}", new { sessionId = sessionId }), 104 | null, null, "GET")))); 105 | } 106 | 107 | #endregion 108 | 109 | 110 | #region user methods 111 | 112 | public async Task RecoverPassword(String username) 113 | { 114 | return HandleResponse(await RestClient.Process( 115 | RestUtility.FormatUrl("/users/{username}/recoverpassword", new { username = username }), new 116 | { 117 | token = Configuration.Token, 118 | countryCode = GetCountryCode() 119 | }, null, "GET")); 120 | } 121 | 122 | #endregion 123 | } 124 | } 125 | -------------------------------------------------------------------------------- /OpenTidl/Methods/OpenTidlLoginMethodsSync.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2016 Jack Fagner 3 | 4 | This file is part of OpenTidl. 5 | 6 | OpenTidl is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU Affero General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | OpenTidl is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU Affero General Public License for more details. 15 | 16 | You should have received a copy of the GNU Affero General Public License 17 | along with OpenTidl. If not, see . 18 | */ 19 | using OpenTidl.Methods; 20 | using OpenTidl.Models; 21 | using OpenTidl.Transport; 22 | using System; 23 | using System.Collections.Generic; 24 | using System.Linq; 25 | using System.Text; 26 | using System.Threading.Tasks; 27 | 28 | namespace OpenTidl 29 | { 30 | public partial class OpenTidlClient 31 | { 32 | #region login methods 33 | 34 | public OpenTidlSession LoginWithFacebook(String accessToken, Int32? timeout) 35 | { 36 | return HelperExtensions.Sync(() => this.LoginWithFacebook(accessToken), timeout); 37 | } 38 | 39 | /*[Obsolete] 40 | public OpenTidlSession LoginWithSpidToken(String accessToken, String spidUserId, Int32? timeout) 41 | { 42 | return HelperExtensions.Sync(() => this.LoginWithSpidToken(accessToken, spidUserId), timeout); 43 | }*/ 44 | 45 | public OpenTidlSession LoginWithToken(String authenticationToken, Int32? timeout) 46 | { 47 | return HelperExtensions.Sync(() => this.LoginWithToken(authenticationToken), timeout); 48 | } 49 | 50 | public OpenTidlSession LoginWithTwitter(String accessToken, String accessTokenSecret, Int32? timeout) 51 | { 52 | return HelperExtensions.Sync(() => this.LoginWithTwitter(accessToken, accessTokenSecret), timeout); 53 | } 54 | 55 | public OpenTidlSession LoginWithUsername(String username, String password, Int32? timeout) 56 | { 57 | return HelperExtensions.Sync(() => this.LoginWithUsername(username, password), timeout); 58 | } 59 | 60 | #endregion 61 | 62 | 63 | #region session methods 64 | 65 | public OpenTidlSession RestoreSession(String sessionId, Int32? timeout) 66 | { 67 | return HelperExtensions.Sync(() => this.RestoreSession(sessionId), timeout); 68 | } 69 | 70 | #endregion 71 | 72 | 73 | #region user methods 74 | 75 | public RecoverPasswordResponseModel RecoverPassword(String username, Int32? timeout) 76 | { 77 | return HelperExtensions.Sync(() => this.RecoverPassword(username), timeout); 78 | } 79 | 80 | #endregion 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /OpenTidl/Methods/OpenTidlPublicMethods.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2015 Jack Fagner 3 | 4 | This file is part of OpenTidl. 5 | 6 | OpenTidl is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU Affero General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | OpenTidl is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU Affero General Public License for more details. 15 | 16 | You should have received a copy of the GNU Affero General Public License 17 | along with OpenTidl. If not, see . 18 | */ 19 | using System; 20 | using System.Collections.Generic; 21 | using System.Linq; 22 | using System.Text; 23 | using System.Threading.Tasks; 24 | using OpenTidl.Models; 25 | using OpenTidl.Models.Base; 26 | using OpenTidl.Transport; 27 | using OpenTidl.Enums; 28 | 29 | namespace OpenTidl 30 | { 31 | public partial class OpenTidlClient 32 | { 33 | #region album methods 34 | 35 | public async Task GetAlbum(Int32 albumId) 36 | { 37 | return HandleResponse(await RestClient.Process( 38 | RestUtility.FormatUrl("/albums/{id}", new { id = albumId }), new 39 | { 40 | token = Configuration.Token, 41 | countryCode = GetCountryCode() 42 | }, null, "GET")); 43 | } 44 | 45 | public async Task> GetAlbums(IEnumerable albumIds) 46 | { 47 | return HandleResponse(await RestClient.Process>( 48 | "/albums", new 49 | { 50 | ids = String.Join(",", albumIds), 51 | token = Configuration.Token, 52 | countryCode = GetCountryCode() 53 | }, null, "GET")); 54 | } 55 | 56 | public async Task> GetSimilarAlbums(Int32 albumId) 57 | { 58 | return HandleResponse(await RestClient.Process>( 59 | RestUtility.FormatUrl("/albums/{id}/similar", new { id = albumId }), new 60 | { 61 | token = Configuration.Token, 62 | countryCode = GetCountryCode() 63 | }, null, "GET")); 64 | } 65 | 66 | public async Task> GetAlbumTracks(Int32 albumId) 67 | { 68 | return HandleResponse(await RestClient.Process>( 69 | RestUtility.FormatUrl("/albums/{id}/tracks", new { id = albumId }), new 70 | { 71 | token = Configuration.Token, 72 | countryCode = GetCountryCode() 73 | }, null, "GET")); 74 | } 75 | 76 | public async Task GetAlbumReview(Int32 albumId) 77 | { 78 | return HandleResponse(await RestClient.Process( 79 | RestUtility.FormatUrl("/albums/{id}/review", new { id = albumId }), new 80 | { 81 | token = Configuration.Token, 82 | countryCode = GetCountryCode() 83 | }, null, "GET")); 84 | } 85 | 86 | #endregion 87 | 88 | 89 | #region artist methods 90 | 91 | public async Task GetArtist(Int32 artistId) 92 | { 93 | return HandleResponse(await RestClient.Process( 94 | RestUtility.FormatUrl("/artists/{id}", new { id = artistId }), new 95 | { 96 | token = Configuration.Token, 97 | countryCode = GetCountryCode() 98 | }, null, "GET")); 99 | } 100 | 101 | public async Task> GetArtistAlbums(Int32 artistId, AlbumFilter filter, Int32 offset = 0, Int32 limit = 9999) 102 | { 103 | return HandleResponse(await RestClient.Process>( 104 | RestUtility.FormatUrl("/artists/{id}/albums", new { id = artistId }), new 105 | { 106 | filter = filter.ToString(), 107 | offset = offset, 108 | limit = limit, 109 | token = Configuration.Token, 110 | countryCode = GetCountryCode() 111 | }, null, "GET")); 112 | } 113 | 114 | public async Task> GetRadioFromArtist(Int32 artistId, Int32 offset = 0, Int32 limit = 9999) 115 | { 116 | return HandleResponse(await RestClient.Process>( 117 | RestUtility.FormatUrl("/artists/{id}/radio", new { id = artistId }), new 118 | { 119 | offset = offset, 120 | limit = limit, 121 | token = Configuration.Token, 122 | countryCode = GetCountryCode() 123 | }, null, "GET")); 124 | } 125 | 126 | public async Task> GetSimilarArtists(Int32 artistId, Int32 offset = 0, Int32 limit = 9999) 127 | { 128 | return HandleResponse(await RestClient.Process>( 129 | RestUtility.FormatUrl("/artists/{id}/similar", new { id = artistId }), new 130 | { 131 | offset = offset, 132 | limit = limit, 133 | token = Configuration.Token, 134 | countryCode = GetCountryCode() 135 | }, null, "GET")); 136 | } 137 | 138 | public async Task> GetArtistTopTracks(Int32 artistId, Int32 offset = 0, Int32 limit = 9999) 139 | { 140 | return HandleResponse(await RestClient.Process>( 141 | RestUtility.FormatUrl("/artists/{id}/toptracks", new { id = artistId }), new 142 | { 143 | offset = offset, 144 | limit = limit, 145 | token = Configuration.Token, 146 | countryCode = GetCountryCode() 147 | }, null, "GET")); 148 | } 149 | 150 | public async Task> GetArtistVideos(Int32 artistId, Int32 offset = 0, Int32 limit = 9999) 151 | { 152 | return HandleResponse(await RestClient.Process>( 153 | RestUtility.FormatUrl("/artists/{id}/videos", new { id = artistId }), new 154 | { 155 | offset = offset, 156 | limit = limit, 157 | token = Configuration.Token, 158 | countryCode = GetCountryCode() 159 | }, null, "GET")); 160 | } 161 | 162 | public async Task GetArtistBiography(Int32 artistId) 163 | { 164 | return HandleResponse(await RestClient.Process( 165 | RestUtility.FormatUrl("/artists/{id}/bio", new { id = artistId }), new 166 | { 167 | token = Configuration.Token, 168 | countryCode = GetCountryCode() 169 | }, null, "GET")); 170 | } 171 | 172 | public async Task> GetArtistLinks(Int32 artistId, Int32 limit = 9999) 173 | { 174 | return HandleResponse(await RestClient.Process>( 175 | RestUtility.FormatUrl("/artists/{id}/links", new { id = artistId }), new 176 | { 177 | limit = limit, 178 | token = Configuration.Token, 179 | countryCode = GetCountryCode() 180 | }, null, "GET")); 181 | } 182 | 183 | #endregion 184 | 185 | 186 | #region country methods 187 | 188 | public async Task GetCountry() 189 | { 190 | return HandleResponse(await RestClient.Process("/country", null, null, "GET")); 191 | } 192 | 193 | #endregion 194 | 195 | 196 | #region search methods 197 | 198 | public async Task> SearchAlbums(String query, Int32 offset = 0, Int32 limit = 9999) 199 | { 200 | return HandleResponse(await RestClient.Process>( 201 | "/search/albums", new 202 | { 203 | query = query, 204 | offset = offset, 205 | limit = limit, 206 | token = Configuration.Token, 207 | countryCode = GetCountryCode() 208 | }, null, "GET")); 209 | } 210 | 211 | public async Task> SearchArtists(String query, Int32 offset = 0, Int32 limit = 9999) 212 | { 213 | return HandleResponse(await RestClient.Process>( 214 | "/search/artists", new 215 | { 216 | query = query, 217 | offset = offset, 218 | limit = limit, 219 | token = Configuration.Token, 220 | countryCode = GetCountryCode() 221 | }, null, "GET")); 222 | } 223 | 224 | public async Task> SearchPlaylists(String query, Int32 offset = 0, Int32 limit = 9999) 225 | { 226 | return HandleResponse(await RestClient.Process>( 227 | "/search/playlists", new 228 | { 229 | query = query, 230 | offset = offset, 231 | limit = limit, 232 | token = Configuration.Token, 233 | countryCode = GetCountryCode() 234 | }, null, "GET")); 235 | } 236 | 237 | public async Task> SearchTracks(String query, Int32 offset = 0, Int32 limit = 9999) 238 | { 239 | return HandleResponse(await RestClient.Process>( 240 | "/search/tracks", new 241 | { 242 | query = query, 243 | offset = offset, 244 | limit = limit, 245 | token = Configuration.Token, 246 | countryCode = GetCountryCode() 247 | }, null, "GET")); 248 | } 249 | 250 | public async Task> SearchVideos(String query, Int32 offset = 0, Int32 limit = 9999) 251 | { 252 | return HandleResponse(await RestClient.Process>( 253 | "/search/videos", new 254 | { 255 | query = query, 256 | offset = offset, 257 | limit = limit, 258 | token = Configuration.Token, 259 | countryCode = GetCountryCode() 260 | }, null, "GET")); 261 | } 262 | 263 | public async Task Search(String query, SearchType types, Int32 offset = 0, Int32 limit = 9999) 264 | { 265 | return HandleResponse(await RestClient.Process( 266 | "/search", new 267 | { 268 | query = query, 269 | types = types.ToString(), 270 | offset = offset, 271 | limit = limit, 272 | token = Configuration.Token, 273 | countryCode = GetCountryCode() 274 | }, null, "GET")); 275 | } 276 | 277 | #endregion 278 | 279 | 280 | #region track methods 281 | 282 | public async Task GetTrack(Int32 trackId) 283 | { 284 | return HandleResponse(await RestClient.Process( 285 | RestUtility.FormatUrl("/tracks/{id}", new { id = trackId }), new 286 | { 287 | token = Configuration.Token, 288 | countryCode = GetCountryCode() 289 | }, null, "GET")); 290 | } 291 | 292 | public async Task> GetTrackContributors(Int32 trackId) 293 | { 294 | return HandleResponse(await RestClient.Process>( 295 | RestUtility.FormatUrl("/tracks/{id}/contributors", new { id = trackId }), new 296 | { 297 | token = Configuration.Token, 298 | countryCode = GetCountryCode() 299 | }, null, "GET")); 300 | } 301 | 302 | public async Task> GetRadioFromTrack(Int32 trackId, Int32 limit = 9999) 303 | { 304 | return HandleResponse(await RestClient.Process>( 305 | RestUtility.FormatUrl("/tracks/{id}/radio", new { id = trackId }), new 306 | { 307 | limit = limit, 308 | token = Configuration.Token, 309 | countryCode = GetCountryCode() 310 | }, null, "GET")); 311 | } 312 | 313 | #endregion 314 | } 315 | } 316 | -------------------------------------------------------------------------------- /OpenTidl/Methods/OpenTidlPublicMethodsSync.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2016 Jack Fagner 3 | 4 | This file is part of OpenTidl. 5 | 6 | OpenTidl is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU Affero General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | OpenTidl is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU Affero General Public License for more details. 15 | 16 | You should have received a copy of the GNU Affero General Public License 17 | along with OpenTidl. If not, see . 18 | */ 19 | using System; 20 | using System.Collections.Generic; 21 | using System.Linq; 22 | using System.Text; 23 | using System.Threading.Tasks; 24 | using OpenTidl.Models; 25 | using OpenTidl.Models.Base; 26 | using OpenTidl.Transport; 27 | using OpenTidl.Enums; 28 | 29 | namespace OpenTidl 30 | { 31 | public partial class OpenTidlClient 32 | { 33 | #region album methods 34 | 35 | public AlbumModel GetAlbum(Int32 albumId, Int32? timeout) 36 | { 37 | return HelperExtensions.Sync(() => this.GetAlbum(albumId), timeout); 38 | } 39 | 40 | public ModelArray GetAlbums(IEnumerable albumIds, Int32? timeout) 41 | { 42 | return HelperExtensions.Sync(() => this.GetAlbums(albumIds), timeout); 43 | } 44 | 45 | public JsonList GetSimilarAlbums(Int32 albumId, Int32? timeout) 46 | { 47 | return HelperExtensions.Sync(() => this.GetSimilarAlbums(albumId), timeout); 48 | } 49 | 50 | public JsonList GetAlbumTracks(Int32 albumId, Int32? timeout) 51 | { 52 | return HelperExtensions.Sync(() => this.GetAlbumTracks(albumId), timeout); 53 | } 54 | 55 | public AlbumReviewModel GetAlbumReview(Int32 albumId, Int32? timeout) 56 | { 57 | return HelperExtensions.Sync(() => this.GetAlbumReview(albumId), timeout); 58 | } 59 | 60 | #endregion 61 | 62 | 63 | #region artist methods 64 | 65 | public ArtistModel GetArtist(Int32 artistId, Int32? timeout) 66 | { 67 | return HelperExtensions.Sync(() => this.GetArtist(artistId), timeout); 68 | } 69 | 70 | public JsonList GetArtistAlbums(Int32 artistId, AlbumFilter filter, Int32? offset, Int32? limit, Int32? timeout) 71 | { 72 | return HelperExtensions.Sync(() => this.GetArtistAlbums(artistId, filter, offset ?? 0, limit ?? 9999), timeout); 73 | } 74 | 75 | public JsonList GetRadioFromArtist(Int32 artistId, Int32? offset, Int32? limit, Int32? timeout) 76 | { 77 | return HelperExtensions.Sync(() => this.GetRadioFromArtist(artistId, offset ?? 0, limit ?? 9999), timeout); 78 | } 79 | 80 | public JsonList GetSimilarArtists(Int32 artistId, Int32? offset, Int32? limit, Int32? timeout) 81 | { 82 | return HelperExtensions.Sync(() => this.GetSimilarArtists(artistId, offset ?? 0, limit ?? 9999), timeout); 83 | } 84 | 85 | public JsonList GetArtistTopTracks(Int32 artistId, Int32? offset, Int32? limit , Int32? timeout) 86 | { 87 | return HelperExtensions.Sync(() => this.GetArtistTopTracks(artistId, offset ?? 0, limit ?? 9999), timeout); 88 | } 89 | 90 | public JsonList GetArtistVideos(Int32 artistId, Int32? offset, Int32? limit, Int32? timeout) 91 | { 92 | return HelperExtensions.Sync(() => this.GetArtistVideos(artistId, offset ?? 0, limit ?? 9999), timeout); 93 | } 94 | 95 | public ArtistBiographyModel GetArtistBiography(Int32 artistId, Int32? timeout) 96 | { 97 | return HelperExtensions.Sync(() => this.GetArtistBiography(artistId), timeout); 98 | } 99 | 100 | public JsonList GetArtistLinks(Int32 artistId, Int32? limit, Int32? timeout) 101 | { 102 | return HelperExtensions.Sync(() => this.GetArtistLinks(artistId, limit ?? 9999), timeout); 103 | } 104 | 105 | #endregion 106 | 107 | 108 | #region country methods 109 | 110 | public CountryModel GetCountry(Int32? timeout) 111 | { 112 | return HelperExtensions.Sync(() => this.GetCountry(), timeout); 113 | } 114 | 115 | #endregion 116 | 117 | 118 | #region search methods 119 | 120 | public JsonList SearchAlbums(String query, Int32? offset, Int32? limit, Int32? timeout) 121 | { 122 | return HelperExtensions.Sync(() => this.SearchAlbums(query, offset ?? 0, limit ?? 9999), timeout); 123 | } 124 | 125 | public JsonList SearchArtists(String query, Int32? offset, Int32? limit, Int32? timeout) 126 | { 127 | return HelperExtensions.Sync(() => this.SearchArtists(query, offset ?? 0, limit ?? 9999), timeout); 128 | } 129 | 130 | public JsonList SearchPlaylists(String query, Int32? offset, Int32? limit, Int32? timeout) 131 | { 132 | return HelperExtensions.Sync(() => this.SearchPlaylists(query, offset ?? 0, limit ?? 9999), timeout); 133 | } 134 | 135 | public JsonList SearchTracks(String query, Int32? offset, Int32? limit, Int32? timeout) 136 | { 137 | return HelperExtensions.Sync(() => this.SearchTracks(query, offset ?? 0, limit ?? 9999), timeout); 138 | } 139 | 140 | public JsonList SearchVideos(String query, Int32? offset, Int32? limit, Int32? timeout) 141 | { 142 | return HelperExtensions.Sync(() => this.SearchVideos(query, offset ?? 0, limit ?? 9999), timeout); 143 | } 144 | 145 | public SearchResultModel Search(String query, SearchType types, Int32? offset, Int32? limit, Int32? timeout) 146 | { 147 | return HelperExtensions.Sync(() => this.Search(query, types, offset ?? 0, limit ?? 9999), timeout); 148 | } 149 | 150 | #endregion 151 | 152 | 153 | #region track methods 154 | 155 | public TrackModel GetTrack(Int32 trackId, Int32? timeout) 156 | { 157 | return HelperExtensions.Sync(() => this.GetTrack(trackId), timeout); 158 | } 159 | 160 | public JsonList GetTrackContributors(Int32 trackId, Int32? timeout) 161 | { 162 | return HelperExtensions.Sync(() => this.GetTrackContributors(trackId), timeout); 163 | } 164 | 165 | public JsonList GetRadioFromTrack(Int32 trackId, Int32? limit, Int32? timeout) 166 | { 167 | return HelperExtensions.Sync(() => this.GetRadioFromTrack(trackId, limit ?? 9999), timeout); 168 | } 169 | 170 | #endregion 171 | } 172 | } 173 | -------------------------------------------------------------------------------- /OpenTidl/Methods/OpenTidlSession.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2015 Jack Fagner 3 | 4 | This file is part of OpenTidl. 5 | 6 | OpenTidl is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU Affero General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | OpenTidl is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU Affero General Public License for more details. 15 | 16 | You should have received a copy of the GNU Affero General Public License 17 | along with OpenTidl. If not, see . 18 | */ 19 | using System; 20 | using System.Collections.Generic; 21 | using System.Linq; 22 | using System.Text; 23 | using System.Threading.Tasks; 24 | using OpenTidl.Enums; 25 | using OpenTidl.Models; 26 | using OpenTidl.Models.Base; 27 | using OpenTidl.Transport; 28 | 29 | namespace OpenTidl.Methods 30 | { 31 | public partial class OpenTidlSession 32 | { 33 | #region properties 34 | 35 | private OpenTidlClient OpenTidlClient { get; set; } 36 | //private RestClient RestClient { get { return OpenTidlClient.RestClient; } } 37 | private RestClient RestClient { get; set; } 38 | 39 | public LoginModel LoginResult { get; private set; } 40 | 41 | //FIXME: Throw error if empty 42 | public String SessionId { get { return LoginResult != null ? LoginResult.SessionId : null; } } 43 | public Int32 UserId { get { return LoginResult != null ? LoginResult.UserId : 0; } } 44 | public String CountryCode { get { return LoginResult != null ? LoginResult.CountryCode : null; } } 45 | 46 | #endregion 47 | 48 | 49 | #region opentidl methods 50 | 51 | 52 | #region logout methods 53 | 54 | public async Task Logout() 55 | { 56 | var result = await RestClient.Process("/logout", new 57 | { 58 | sessionId = SessionId, 59 | countryCode = CountryCode 60 | }, new { }, "POST"); 61 | 62 | if (result == null || result.Exception == null) 63 | this.LoginResult = null; //Clear session 64 | return HandleResponse(result); 65 | } 66 | 67 | #endregion 68 | 69 | 70 | #region playlist methods 71 | 72 | public async Task GetPlaylist(String playlistUuid) 73 | { 74 | return HandleResponse(await RestClient.Process( 75 | RestUtility.FormatUrl("/playlists/{uuid}", new { uuid = playlistUuid }), new 76 | { 77 | sessionId = SessionId, 78 | countryCode = CountryCode 79 | }, null, "GET")); 80 | } 81 | 82 | public async Task> GetPlaylistTracks(String playlistUuid, Int32 offset = 0, Int32 limit = 9999) 83 | { 84 | return HandleResponse(await RestClient.Process>( 85 | RestUtility.FormatUrl("/playlists/{uuid}/tracks", new { uuid = playlistUuid }), new 86 | { 87 | offset = offset, 88 | limit = limit, 89 | sessionId = SessionId, 90 | countryCode = CountryCode 91 | }, null, "GET")); 92 | } 93 | 94 | public async Task AddPlaylistTracks(String playlistUuid, String playlistETag, IEnumerable trackIds, Int32 toIndex = 0) 95 | { 96 | return HandleResponse(await RestClient.Process( 97 | RestUtility.FormatUrl("/playlists/{uuid}/tracks", new { uuid = playlistUuid }), new 98 | { 99 | sessionId = SessionId, 100 | countryCode = CountryCode 101 | }, new 102 | { 103 | trackIds = String.Join(",", trackIds), 104 | toIndex = toIndex 105 | }, "POST", 106 | Header("If-None-Match", playlistETag))); 107 | } 108 | 109 | public async Task DeletePlaylistTracks(String playlistUuid, String playlistETag, IEnumerable indices) 110 | { 111 | return HandleResponse(await RestClient.Process( 112 | RestUtility.FormatUrl("/playlists/{uuid}/tracks/{indices}", new 113 | { 114 | uuid = playlistUuid, 115 | indices = String.Join(",", indices) 116 | }), new 117 | { 118 | sessionId = SessionId, 119 | countryCode = CountryCode 120 | }, null, "DELETE", 121 | Header("If-None-Match", playlistETag))); 122 | } 123 | 124 | public async Task DeletePlaylist(String playlistUuid, String playlistETag) 125 | { 126 | return HandleResponse(await RestClient.Process( 127 | RestUtility.FormatUrl("/playlists/{uuid}", new 128 | { 129 | uuid = playlistUuid 130 | }), new 131 | { 132 | sessionId = SessionId, 133 | countryCode = CountryCode 134 | }, null, "DELETE", 135 | Header("If-None-Match", playlistETag))); 136 | } 137 | 138 | public async Task MovePlaylistTracks(String playlistUuid, String playlistETag, IEnumerable indices, Int32 toIndex = 0) 139 | { 140 | return HandleResponse(await RestClient.Process( 141 | RestUtility.FormatUrl("/playlists/{uuid}/tracks/{indices}", new 142 | { 143 | uuid = playlistUuid, 144 | indices = String.Join(",", indices) 145 | }), new 146 | { 147 | sessionId = SessionId, 148 | countryCode = CountryCode 149 | }, new 150 | { 151 | toIndex = toIndex 152 | }, "POST", 153 | Header("If-None-Match", playlistETag))); 154 | } 155 | 156 | public async Task UpdatePlaylist(String playlistUuid, String playlistETag, String title) 157 | { 158 | return HandleResponse(await RestClient.Process( 159 | RestUtility.FormatUrl("/playlists/{uuid}", new 160 | { 161 | uuid = playlistUuid 162 | }), new 163 | { 164 | sessionId = SessionId, 165 | countryCode = CountryCode 166 | }, new 167 | { 168 | title = title 169 | }, "POST", 170 | Header("If-None-Match", playlistETag))); 171 | } 172 | 173 | #endregion 174 | 175 | 176 | #region session methods 177 | 178 | public async Task GetClient() 179 | { 180 | return HandleResponse(await RestClient.Process( 181 | RestUtility.FormatUrl("/sessions/{sessionId}/client", new { sessionId = SessionId }), 182 | null, null, "GET")); 183 | } 184 | 185 | public async Task GetSession() 186 | { 187 | return HandleResponse(await RestClient.Process( 188 | RestUtility.FormatUrl("/sessions/{sessionId}", new { sessionId = SessionId }), 189 | null, null, "GET")); 190 | } 191 | 192 | #endregion 193 | 194 | 195 | #region track methods 196 | 197 | public async Task GetTrackStreamUrl(Int32 trackId, SoundQuality soundQuality, String playlistUuid) 198 | { 199 | return HandleResponse(await RestClient.Process( 200 | RestUtility.FormatUrl("/tracks/{id}/streamUrl", new { id = trackId }), new 201 | { 202 | soundQuality = soundQuality, 203 | playlistUuid = playlistUuid, 204 | sessionId = SessionId, 205 | countryCode = CountryCode 206 | }, null, "GET")); 207 | } 208 | 209 | public async Task GetTrackOfflineUrl(Int32 trackId, SoundQuality soundQuality) 210 | { 211 | return HandleResponse(await RestClient.Process( 212 | RestUtility.FormatUrl("/tracks/{id}/offlineUrl", new { id = trackId }), new 213 | { 214 | soundQuality = soundQuality, 215 | sessionId = SessionId, 216 | countryCode = CountryCode 217 | }, null, "GET")); 218 | } 219 | 220 | #endregion 221 | 222 | 223 | #region user methods 224 | 225 | public async Task> GetUserClients(ClientFilter filter, Int32 limit = 9999) 226 | { 227 | return HandleResponse(await RestClient.Process>( 228 | RestUtility.FormatUrl("/users/{userId}/clients", new { userId = UserId }), new 229 | { 230 | filter = filter.ToString(), 231 | limit = limit, 232 | sessionId = SessionId, 233 | countryCode = CountryCode 234 | }, null, "GET")); 235 | } 236 | 237 | public async Task> GetUserPlaylists(Int32 limit = 9999) 238 | { 239 | return HandleResponse(await RestClient.Process>( 240 | RestUtility.FormatUrl("/users/{userId}/playlists", new { userId = UserId }), new 241 | { 242 | limit = limit, 243 | sessionId = SessionId, 244 | countryCode = CountryCode 245 | }, null, "GET")); 246 | } 247 | 248 | public async Task CreateUserPlaylist(String title) 249 | { 250 | return HandleResponse(await RestClient.Process( 251 | RestUtility.FormatUrl("/users/{userId}/playlists", new { userId = UserId }), new 252 | { 253 | sessionId = SessionId, 254 | countryCode = CountryCode 255 | }, new 256 | { 257 | title = title 258 | }, "POST")); 259 | } 260 | 261 | public async Task GetUserSubscription() 262 | { 263 | return HandleResponse(await RestClient.Process( 264 | RestUtility.FormatUrl("/users/{userId}/subscription", new { userId = UserId }), new 265 | { 266 | sessionId = SessionId, 267 | countryCode = CountryCode 268 | }, null, "GET")); 269 | } 270 | 271 | public async Task GetUser() 272 | { 273 | return HandleResponse(await RestClient.Process( 274 | RestUtility.FormatUrl("/users/{userId}", new { userId = UserId }), new 275 | { 276 | sessionId = SessionId, 277 | countryCode = CountryCode 278 | }, null, "GET")); 279 | } 280 | 281 | #endregion 282 | 283 | 284 | #region user favorites methods 285 | 286 | public async Task>> GetFavoriteAlbums(Int32 limit = 9999) 287 | { 288 | return HandleResponse(await RestClient.Process>>( 289 | RestUtility.FormatUrl("/users/{userId}/favorites/albums", new { userId = UserId }), new 290 | { 291 | limit = limit, 292 | sessionId = SessionId, 293 | countryCode = CountryCode 294 | }, null, "GET")); 295 | } 296 | 297 | public async Task>> GetFavoriteArtists(Int32 limit = 9999) 298 | { 299 | return HandleResponse(await RestClient.Process>>( 300 | RestUtility.FormatUrl("/users/{userId}/favorites/artists", new { userId = UserId }), new 301 | { 302 | limit = limit, 303 | sessionId = SessionId, 304 | countryCode = CountryCode 305 | }, null, "GET")); 306 | } 307 | 308 | public async Task>> GetFavoritePlaylists(Int32 limit = 9999) 309 | { 310 | return HandleResponse(await RestClient.Process>>( 311 | RestUtility.FormatUrl("/users/{userId}/favorites/playlists", new { userId = UserId }), new 312 | { 313 | limit = limit, 314 | sessionId = SessionId, 315 | countryCode = CountryCode 316 | }, null, "GET")); 317 | } 318 | 319 | public async Task>> GetFavoriteTracks(Int32 limit = 9999) 320 | { 321 | return HandleResponse(await RestClient.Process>>( 322 | RestUtility.FormatUrl("/users/{userId}/favorites/tracks", new { userId = UserId }), new 323 | { 324 | limit = limit, 325 | sessionId = SessionId, 326 | countryCode = CountryCode 327 | }, null, "GET")); 328 | } 329 | 330 | public async Task AddFavoriteAlbum(Int32 albumId) 331 | { 332 | return HandleResponse(await RestClient.Process( 333 | RestUtility.FormatUrl("/users/{userId}/favorites/albums", new { userId = UserId }), new 334 | { 335 | sessionId = SessionId, 336 | countryCode = CountryCode 337 | }, new { 338 | albumId = albumId 339 | }, "POST")); 340 | } 341 | 342 | public async Task AddFavoriteArtist(Int32 artistId) 343 | { 344 | return HandleResponse(await RestClient.Process( 345 | RestUtility.FormatUrl("/users/{userId}/favorites/artists", new { userId = UserId }), new 346 | { 347 | sessionId = SessionId, 348 | countryCode = CountryCode 349 | }, new 350 | { 351 | artistId = artistId 352 | }, "POST")); 353 | } 354 | 355 | public async Task AddFavoritePlaylist(String playlistUuid) 356 | { 357 | return HandleResponse(await RestClient.Process( 358 | RestUtility.FormatUrl("/users/{userId}/favorites/playlists", new { userId = UserId }), new 359 | { 360 | sessionId = SessionId, 361 | countryCode = CountryCode 362 | }, new 363 | { 364 | uuid = playlistUuid 365 | }, "POST")); 366 | } 367 | 368 | public async Task AddFavoriteTrack(Int32 trackId) 369 | { 370 | return HandleResponse(await RestClient.Process( 371 | RestUtility.FormatUrl("/users/{userId}/favorites/tracks", new { userId = UserId }), new 372 | { 373 | sessionId = SessionId, 374 | countryCode = CountryCode 375 | }, new 376 | { 377 | trackId = trackId 378 | }, "POST")); 379 | } 380 | 381 | public async Task RemoveFavoriteAlbum(Int32 albumId) 382 | { 383 | return HandleResponse(await RestClient.Process( 384 | RestUtility.FormatUrl("/users/{userId}/favorites/albums/{albumId}", new 385 | { 386 | userId = UserId, 387 | albumId = albumId 388 | }), new 389 | { 390 | sessionId = SessionId, 391 | countryCode = CountryCode 392 | }, null, "DELETE")); 393 | } 394 | 395 | public async Task RemoveFavoriteArtist(Int32 artistId) 396 | { 397 | return HandleResponse(await RestClient.Process( 398 | RestUtility.FormatUrl("/users/{userId}/favorites/artists/{artistId}", new 399 | { 400 | userId = UserId, 401 | artistId = artistId 402 | }), new 403 | { 404 | sessionId = SessionId, 405 | countryCode = CountryCode 406 | }, null, "DELETE")); 407 | } 408 | 409 | public async Task RemoveFavoritePlaylist(String playlistUuid) 410 | { 411 | return HandleResponse(await RestClient.Process( 412 | RestUtility.FormatUrl("/users/{userId}/favorites/playlists/{uuid}", new 413 | { 414 | userId = UserId, 415 | uuid = playlistUuid 416 | }), new 417 | { 418 | sessionId = SessionId, 419 | countryCode = CountryCode 420 | }, null, "DELETE")); 421 | } 422 | 423 | public async Task RemoveFavoriteTrack(Int32 trackId) 424 | { 425 | return HandleResponse(await RestClient.Process( 426 | RestUtility.FormatUrl("/users/{userId}/favorites/tracks/{trackId}", new 427 | { 428 | userId = UserId, 429 | trackId = trackId 430 | }), new 431 | { 432 | sessionId = SessionId, 433 | countryCode = CountryCode 434 | }, null, "DELETE")); 435 | } 436 | 437 | #endregion 438 | 439 | 440 | #region video methods 441 | 442 | public async Task GetVideo(Int32 videoId) 443 | { 444 | return HandleResponse(await RestClient.Process( 445 | RestUtility.FormatUrl("/videos/{id}", new { id = videoId }), new 446 | { 447 | sessionId = SessionId, 448 | countryCode = CountryCode 449 | }, null, "GET")); 450 | } 451 | 452 | public async Task GetVideoStreamUrl(Int32 videoId, VideoQuality videoQuality) 453 | { 454 | return HandleResponse(await RestClient.Process( 455 | RestUtility.FormatUrl("/videos/{id}/streamurl", new { id = videoId }), new 456 | { 457 | videoQuality = videoQuality, 458 | sessionId = SessionId, 459 | countryCode = CountryCode 460 | }, null, "GET")); 461 | } 462 | 463 | #endregion 464 | 465 | 466 | #endregion 467 | 468 | 469 | #region methods 470 | 471 | private T HandleResponse(RestResponse response) where T : ModelBase 472 | { 473 | return this.OpenTidlClient.HandleResponse(response); 474 | } 475 | 476 | private KeyValuePair Header(String header, String value) 477 | { 478 | return this.OpenTidlClient.Header(header, value); 479 | } 480 | 481 | #endregion 482 | 483 | 484 | #region construction 485 | 486 | internal OpenTidlSession(OpenTidlClient client, LoginModel loginModel) 487 | { 488 | this.OpenTidlClient = client; 489 | this.LoginResult = loginModel; 490 | this.RestClient = new RestClient(client.Configuration.ApiEndpoint, client.Configuration.UserAgent, Header("X-Tidal-SessionId", loginModel?.SessionId ?? "")); 491 | } 492 | 493 | #endregion 494 | } 495 | } 496 | -------------------------------------------------------------------------------- /OpenTidl/Methods/OpenTidlSessionSync.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2016 Jack Fagner 3 | 4 | This file is part of OpenTidl. 5 | 6 | OpenTidl is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU Affero General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | OpenTidl is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU Affero General Public License for more details. 15 | 16 | You should have received a copy of the GNU Affero General Public License 17 | along with OpenTidl. If not, see . 18 | */ 19 | using System; 20 | using System.Collections.Generic; 21 | using System.Linq; 22 | using System.Text; 23 | using System.Threading.Tasks; 24 | using OpenTidl.Enums; 25 | using OpenTidl.Models; 26 | using OpenTidl.Models.Base; 27 | using OpenTidl.Transport; 28 | 29 | namespace OpenTidl.Methods 30 | { 31 | public partial class OpenTidlSession 32 | { 33 | #region opentidl methods 34 | 35 | 36 | #region logout methods 37 | 38 | public EmptyModel Logout(Int32? timeout) 39 | { 40 | return HelperExtensions.Sync(() => this.Logout(), timeout); 41 | } 42 | 43 | #endregion 44 | 45 | 46 | #region playlist methods 47 | 48 | public PlaylistModel GetPlaylist(String playlistUuid, Int32? timeout) 49 | { 50 | return HelperExtensions.Sync(() => this.GetPlaylist(playlistUuid), timeout); 51 | } 52 | 53 | public JsonList GetPlaylistTracks(String playlistUuid, Int32? offset, Int32? limit, Int32? timeout) 54 | { 55 | return HelperExtensions.Sync(() => this.GetPlaylistTracks(playlistUuid, offset ?? 0, limit ?? 9999), timeout); 56 | } 57 | 58 | public EmptyModel AddPlaylistTracks(String playlistUuid, String playlistETag, IEnumerable trackIds, Int32? toIndex, Int32? timeout) 59 | { 60 | return HelperExtensions.Sync(() => this.AddPlaylistTracks(playlistUuid, playlistETag, trackIds, toIndex ?? 0), timeout); 61 | } 62 | 63 | public EmptyModel DeletePlaylistTracks(String playlistUuid, String playlistETag, IEnumerable indices, Int32? timeout) 64 | { 65 | return HelperExtensions.Sync(() => this.DeletePlaylistTracks(playlistUuid, playlistETag, indices), timeout); 66 | } 67 | 68 | public EmptyModel DeletePlaylist(String playlistUuid, String playlistETag, Int32? timeout) 69 | { 70 | return HelperExtensions.Sync(() => this.DeletePlaylist(playlistUuid, playlistETag), timeout); 71 | } 72 | 73 | public EmptyModel MovePlaylistTracks(String playlistUuid, String playlistETag, IEnumerable indices, Int32? toIndex, Int32? timeout) 74 | { 75 | return HelperExtensions.Sync(() => this.MovePlaylistTracks(playlistUuid, playlistETag, indices, toIndex ?? 0), timeout); 76 | } 77 | 78 | public EmptyModel UpdatePlaylist(String playlistUuid, String playlistETag, String title, Int32? timeout) 79 | { 80 | return HelperExtensions.Sync(() => this.UpdatePlaylist(playlistUuid, playlistETag, title), timeout); 81 | } 82 | 83 | #endregion 84 | 85 | 86 | #region session methods 87 | 88 | public ClientModel GetClient(Int32? timeout) 89 | { 90 | return HelperExtensions.Sync(() => this.GetClient(), timeout); 91 | } 92 | 93 | public SessionModel GetSession(Int32? timeout) 94 | { 95 | return HelperExtensions.Sync(() => this.GetSession(), timeout); 96 | } 97 | 98 | #endregion 99 | 100 | 101 | #region track methods 102 | 103 | public StreamUrlModel GetTrackStreamUrl(Int32 trackId, SoundQuality soundQuality, String playlistUuid, Int32? timeout) 104 | { 105 | return HelperExtensions.Sync(() => this.GetTrackStreamUrl(trackId, soundQuality, playlistUuid), timeout); 106 | } 107 | 108 | public StreamUrlModel GetTrackOfflineUrl(Int32 trackId, SoundQuality soundQuality, Int32? timeout) 109 | { 110 | return HelperExtensions.Sync(() => this.GetTrackOfflineUrl(trackId, soundQuality), timeout); 111 | } 112 | 113 | #endregion 114 | 115 | 116 | #region user methods 117 | 118 | public JsonList GetUserClients(ClientFilter filter, Int32? limit, Int32? timeout) 119 | { 120 | return HelperExtensions.Sync(() => this.GetUserClients(filter, limit ?? 9999), timeout); 121 | } 122 | 123 | public JsonList GetUserPlaylists(Int32? limit, Int32? timeout) 124 | { 125 | return HelperExtensions.Sync(() => this.GetUserPlaylists(limit ?? 9999), timeout); 126 | } 127 | 128 | public PlaylistModel CreateUserPlaylist(String title, Int32? timeout) 129 | { 130 | return HelperExtensions.Sync(() => this.CreateUserPlaylist(title), timeout); 131 | } 132 | 133 | public UserSubscriptionModel GetUserSubscription(Int32? timeout) 134 | { 135 | return HelperExtensions.Sync(() => this.GetUserSubscription(), timeout); 136 | } 137 | 138 | public UserModel GetUser(Int32? timeout) 139 | { 140 | return HelperExtensions.Sync(() => this.GetUser(), timeout); 141 | } 142 | 143 | #endregion 144 | 145 | 146 | #region user favorites methods 147 | 148 | public JsonList> GetFavoriteAlbums(Int32? limit, Int32? timeout) 149 | { 150 | return HelperExtensions.Sync(() => this.GetFavoriteAlbums(limit ?? 9999), timeout); 151 | } 152 | 153 | public JsonList> GetFavoriteArtists(Int32? limit, Int32? timeout) 154 | { 155 | return HelperExtensions.Sync(() => this.GetFavoriteArtists(limit ?? 9999), timeout); 156 | } 157 | 158 | public JsonList> GetFavoritePlaylists(Int32? limit, Int32? timeout) 159 | { 160 | return HelperExtensions.Sync(() => this.GetFavoritePlaylists(limit ?? 9999), timeout); 161 | } 162 | 163 | public JsonList> GetFavoriteTracks(Int32? limit, Int32? timeout) 164 | { 165 | return HelperExtensions.Sync(() => this.GetFavoriteTracks(limit ?? 9999), timeout); 166 | } 167 | 168 | public EmptyModel AddFavoriteAlbum(Int32 albumId, Int32? timeout) 169 | { 170 | return HelperExtensions.Sync(() => this.AddFavoriteAlbum(albumId), timeout); 171 | } 172 | 173 | public EmptyModel AddFavoriteArtist(Int32 artistId, Int32? timeout) 174 | { 175 | return HelperExtensions.Sync(() => this.AddFavoriteArtist(artistId), timeout); 176 | } 177 | 178 | public EmptyModel AddFavoritePlaylist(String playlistUuid, Int32? timeout) 179 | { 180 | return HelperExtensions.Sync(() => this.AddFavoritePlaylist(playlistUuid), timeout); 181 | } 182 | 183 | public EmptyModel AddFavoriteTrack(Int32 trackId, Int32? timeout) 184 | { 185 | return HelperExtensions.Sync(() => this.AddFavoriteTrack(trackId), timeout); 186 | } 187 | 188 | public EmptyModel RemoveFavoriteAlbum(Int32 albumId, Int32? timeout) 189 | { 190 | return HelperExtensions.Sync(() => this.RemoveFavoriteAlbum(albumId), timeout); 191 | } 192 | 193 | public EmptyModel RemoveFavoriteArtist(Int32 artistId, Int32? timeout) 194 | { 195 | return HelperExtensions.Sync(() => this.RemoveFavoriteArtist(artistId), timeout); 196 | } 197 | 198 | public EmptyModel RemoveFavoritePlaylist(String playlistUuid, Int32? timeout) 199 | { 200 | return HelperExtensions.Sync(() => this.RemoveFavoritePlaylist(playlistUuid), timeout); 201 | } 202 | 203 | public EmptyModel RemoveFavoriteTrack(Int32 trackId, Int32? timeout) 204 | { 205 | return HelperExtensions.Sync(() => this.RemoveFavoriteTrack(trackId), timeout); 206 | } 207 | 208 | #endregion 209 | 210 | 211 | #region video methods 212 | 213 | public VideoModel GetVideo(Int32 videoId, Int32? timeout) 214 | { 215 | return HelperExtensions.Sync(() => this.GetVideo(videoId), timeout); 216 | } 217 | 218 | public VideoStreamUrlModel GetVideoStreamUrl(Int32 videoId, VideoQuality videoQuality, Int32? timeout) 219 | { 220 | return HelperExtensions.Sync(() => this.GetVideoStreamUrl(videoId, videoQuality), timeout); 221 | } 222 | 223 | #endregion 224 | 225 | 226 | #endregion 227 | } 228 | } 229 | -------------------------------------------------------------------------------- /OpenTidl/Methods/OpenTidlStreamMethods.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2015 Jack Fagner 3 | 4 | This file is part of OpenTidl. 5 | 6 | OpenTidl is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU Affero General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | OpenTidl is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU Affero General Public License for more details. 15 | 16 | You should have received a copy of the GNU Affero General Public License 17 | along with OpenTidl. If not, see . 18 | */ 19 | using System; 20 | using System.Collections.Generic; 21 | using System.Linq; 22 | using System.Text; 23 | using System.Threading.Tasks; 24 | using OpenTidl.Models; 25 | using OpenTidl.Models.Base; 26 | using OpenTidl.Transport; 27 | using OpenTidl.Enums; 28 | using System.IO; 29 | 30 | namespace OpenTidl 31 | { 32 | public partial class OpenTidlClient 33 | { 34 | #region image methods 35 | 36 | /// 37 | /// Helper method to retrieve a stream with an album cover image 38 | /// 39 | public WebStreamModel GetAlbumCover(AlbumModel model, AlbumCoverSize size) 40 | { 41 | return GetAlbumCover(model.Cover, model.Id, size); 42 | } 43 | 44 | /// 45 | /// Helper method to retrieve a stream with an album cover image 46 | /// 47 | public WebStreamModel GetAlbumCover(String cover, Int32 albumId, AlbumCoverSize size) 48 | { 49 | var w = 750; 50 | var h = 750; 51 | if (!RestUtility.ParseImageSize(size.ToString(), out w, out h)) 52 | throw new ArgumentException("Invalid image size", "size"); 53 | String url = null; 54 | if (!String.IsNullOrEmpty(cover)) 55 | url = String.Format("http://resources.wimpmusic.com/images/{0}/{1}x{2}.jpg", cover.Replace('-', '/'), w, h); 56 | else 57 | url = String.Format("http://images.tidalhifi.com/im/im?w={1}&h={2}&albumid={0}&noph", albumId, w, h); 58 | return new WebStreamModel(RestClient.GetWebResponse(url)); 59 | } 60 | 61 | /// 62 | /// Helper method to retrieve a stream with an artists picture 63 | /// 64 | public WebStreamModel GetArtistPicture(ArtistModel model, ArtistPictureSize size) 65 | { 66 | return GetArtistPicture(model.Picture, model.Id, size); 67 | } 68 | 69 | /// 70 | /// Helper method to retrieve a stream with an artists picture 71 | /// 72 | public WebStreamModel GetArtistPicture(String picture, Int32 artistId, ArtistPictureSize size) 73 | { 74 | var w = 750; 75 | var h = 500; 76 | if (!RestUtility.ParseImageSize(size.ToString(), out w, out h)) 77 | throw new ArgumentException("Invalid image size", "size"); 78 | String url = null; 79 | if (!String.IsNullOrEmpty(picture)) 80 | url = String.Format("http://resources.wimpmusic.com/images/{0}/{1}x{2}.jpg", picture.Replace('-', '/'), w, h); 81 | else 82 | url = String.Format("http://images.tidalhifi.com/im/im?w={1}&h={2}&artistid={0}&noph", artistId, w, h); 83 | return new WebStreamModel(RestClient.GetWebResponse(url)); 84 | } 85 | 86 | /// 87 | /// Helper method to retrieve a stream with a playlist image 88 | /// 89 | public WebStreamModel GetPlaylistImage(PlaylistModel model, PlaylistImageSize size) 90 | { 91 | return GetPlaylistImage(model.Image, model.Uuid, size); 92 | } 93 | 94 | /// 95 | /// Helper method to retrieve a stream with a playlist image 96 | /// 97 | public WebStreamModel GetPlaylistImage(String image, String playlistUuid, PlaylistImageSize size) 98 | { 99 | var w = 750; 100 | var h = 500; 101 | if (!RestUtility.ParseImageSize(size.ToString(), out w, out h)) 102 | throw new ArgumentException("Invalid image size", "size"); 103 | String url = null; 104 | if (!String.IsNullOrEmpty(image)) 105 | url = String.Format("http://resources.wimpmusic.com/images/{0}/{1}x{2}.jpg", image.Replace('-', '/'), w, h); 106 | else 107 | url = String.Format("http://images.tidalhifi.com/im/im?w={1}&h={2}&uuid={0}&rows=2&cols=3&noph", playlistUuid, w, h); 108 | return new WebStreamModel(RestClient.GetWebResponse(url)); 109 | } 110 | 111 | /// 112 | /// Helper method to retrieve a stream with a video conver image 113 | /// 114 | public WebStreamModel GetVideoImage(VideoModel model, VideoImageSize size) 115 | { 116 | return GetVideoImage(model.ImageId, model.ImagePath, size); 117 | } 118 | 119 | /// 120 | /// Helper method to retrieve a stream with a video conver image 121 | /// 122 | public WebStreamModel GetVideoImage(String imageId, String imagePath, VideoImageSize size) 123 | { 124 | var w = 750; 125 | var h = 500; 126 | if (!RestUtility.ParseImageSize(size.ToString(), out w, out h)) 127 | throw new ArgumentException("Invalid image size", "size"); 128 | String url = null; 129 | if (!String.IsNullOrEmpty(imageId)) 130 | url = String.Format("http://resources.wimpmusic.com/images/{0}/{1}x{2}.jpg", imageId.Replace('-', '/'), w, h); 131 | else 132 | url = String.Format("http://images.tidalhifi.com/im/im?w={1}&h={2}&img={0}&noph", imagePath, w, h); 133 | return new WebStreamModel(RestClient.GetWebResponse(url)); 134 | } 135 | 136 | #endregion 137 | 138 | 139 | #region track/video methods 140 | 141 | /// 142 | /// Helper method to retrieve the audio/video stream with correct user-agent, etc. 143 | /// 144 | public WebStreamModel GetWebStream(String streamUrl) 145 | { 146 | return new WebStreamModel(RestClient.GetWebResponse(streamUrl)); 147 | } 148 | 149 | #endregion 150 | } 151 | } 152 | -------------------------------------------------------------------------------- /OpenTidl/Models/AlbumModel.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2015 Jack Fagner 3 | 4 | This file is part of OpenTidl. 5 | 6 | OpenTidl is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU Affero General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | OpenTidl is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU Affero General Public License for more details. 15 | 16 | You should have received a copy of the GNU Affero General Public License 17 | along with OpenTidl. If not, see . 18 | */ 19 | using System; 20 | using System.Collections.Generic; 21 | using System.Linq; 22 | using System.Text; 23 | using System.Threading.Tasks; 24 | using OpenTidl.Models.Base; 25 | using System.Runtime.Serialization; 26 | using OpenTidl.Transport; 27 | using OpenTidl.Enums; 28 | using System.IO; 29 | 30 | namespace OpenTidl.Models 31 | { 32 | [DataContract] 33 | public class AlbumModel : ModelBase 34 | { 35 | [DataMember(Name = "allowStreaming")] 36 | public Boolean AllowStreaming { get; private set; } 37 | 38 | [DataMember(Name = "artist")] 39 | public ArtistModel Artist { get; private set; } 40 | 41 | [DataMember(Name = "artists")] 42 | public ArtistModel[] Artists { get; private set; } 43 | 44 | [DataMember(Name = "copyright")] 45 | public String Copyright { get; private set; } 46 | 47 | [DataMember(Name = "cover")] 48 | public String Cover { get; private set; } 49 | 50 | [DataMember(Name = "duration")] 51 | public Int32 Duration { get; private set; } 52 | 53 | [DataMember(Name = "id")] 54 | public Int32 Id { get; private set; } 55 | 56 | [DataMember(Name = "numberOfTracks")] 57 | public Int32 NumberOfTracks { get; private set; } 58 | 59 | [DataMember(Name = "numberOfVolumes")] 60 | public Int32 NumberOfVolumes { get; private set; } 61 | 62 | [DataMember(Name = "offlineDateAdded")] 63 | public Int64 OfflineDateAdded { get; private set; } 64 | 65 | [IgnoreDataMember] 66 | public DateTime? ReleaseDate { get; private set; } 67 | 68 | [DataMember(Name = "streamReady")] 69 | public Boolean StreamReady { get; private set; } 70 | 71 | [IgnoreDataMember] 72 | public DateTime? StreamStartDate { get; private set; } 73 | 74 | [DataMember(Name = "title")] 75 | public String Title { get; private set; } 76 | 77 | 78 | [DataMember(Name = "url")] 79 | public String Url { get; private set; } 80 | 81 | [DataMember(Name = "version")] 82 | public String Version { get; private set; } 83 | 84 | [DataMember(Name = "type")] 85 | public String Type { get; private set; } 86 | 87 | [DataMember(Name = "premiumStreamingOnly")] 88 | public Boolean PremiumStreamingOnly { get; private set; } 89 | 90 | [DataMember(Name = "upc")] 91 | public String Upc { get; private set; } 92 | 93 | [DataMember(Name = "audioQuality")] 94 | public String AudioQuality { get; private set; } 95 | 96 | 97 | #region json helpers 98 | 99 | [DataMember(Name = "releaseDate")] 100 | private String ReleaseDateHelper 101 | { 102 | get { return RestUtility.FormatDate(ReleaseDate); } 103 | set { ReleaseDate = RestUtility.ParseDate(value); } 104 | } 105 | 106 | [DataMember(Name = "streamStartDate")] 107 | private String StreamStartDateHelper 108 | { 109 | get { return RestUtility.FormatDate(StreamStartDate); } 110 | set { StreamStartDate = RestUtility.ParseDate(value); } 111 | } 112 | 113 | #endregion 114 | } 115 | } 116 | -------------------------------------------------------------------------------- /OpenTidl/Models/AlbumReviewModel.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2015 Jack Fagner 3 | 4 | This file is part of OpenTidl. 5 | 6 | OpenTidl is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU Affero General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | OpenTidl is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU Affero General Public License for more details. 15 | 16 | You should have received a copy of the GNU Affero General Public License 17 | along with OpenTidl. If not, see . 18 | */ 19 | using System; 20 | using System.Collections.Generic; 21 | using System.Linq; 22 | using System.Text; 23 | using System.Threading.Tasks; 24 | using OpenTidl.Models.Base; 25 | using System.Runtime.Serialization; 26 | using OpenTidl.Transport; 27 | 28 | namespace OpenTidl.Models 29 | { 30 | [DataContract] 31 | public class AlbumReviewModel : ModelBase 32 | { 33 | [DataMember(Name = "source")] 34 | public String Source { get; private set; } 35 | 36 | [DataMember(Name = "text")] 37 | public String Text { get; private set; } 38 | 39 | 40 | [DataMember(Name = "summary")] 41 | public String Summary { get; private set; } 42 | 43 | [IgnoreDataMember] 44 | public DateTime? LastUpdated { get; private set; } 45 | 46 | 47 | #region json helpers 48 | 49 | [DataMember(Name = "lastUpdated")] 50 | private String LastUpdatedDateHelper 51 | { 52 | get { return RestUtility.FormatDate(LastUpdated); } 53 | set { LastUpdated = RestUtility.ParseDate(value); } 54 | } 55 | 56 | #endregion 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /OpenTidl/Models/ApplicationModel.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2015 Jack Fagner 3 | 4 | This file is part of OpenTidl. 5 | 6 | OpenTidl is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU Affero General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | OpenTidl is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU Affero General Public License for more details. 15 | 16 | You should have received a copy of the GNU Affero General Public License 17 | along with OpenTidl. If not, see . 18 | */ 19 | using System; 20 | using System.Collections.Generic; 21 | using System.Linq; 22 | using System.Text; 23 | using System.Threading.Tasks; 24 | using OpenTidl.Models.Base; 25 | using System.Runtime.Serialization; 26 | 27 | namespace OpenTidl.Models 28 | { 29 | [DataContract] 30 | public class ApplicationModel : ModelBase 31 | { 32 | [DataMember(Name = "name")] 33 | public String Name { get; private set; } 34 | 35 | [DataMember(Name = "type")] 36 | public ApplicationTypeModel Type { get; private set; } 37 | 38 | [DataMember(Name = "service")] 39 | public String Service { get; private set; } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /OpenTidl/Models/ApplicationTypeModel.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2015 Jack Fagner 3 | 4 | This file is part of OpenTidl. 5 | 6 | OpenTidl is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU Affero General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | OpenTidl is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU Affero General Public License for more details. 15 | 16 | You should have received a copy of the GNU Affero General Public License 17 | along with OpenTidl. If not, see . 18 | */ 19 | using System; 20 | using System.Collections.Generic; 21 | using System.Linq; 22 | using System.Text; 23 | using System.Threading.Tasks; 24 | using OpenTidl.Models.Base; 25 | using System.Runtime.Serialization; 26 | 27 | namespace OpenTidl.Models 28 | { 29 | [DataContract] 30 | public class ApplicationTypeModel : ModelBase 31 | { 32 | [DataMember(Name = "name")] 33 | public String Name { get; private set; } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /OpenTidl/Models/ArtistBiographyModel.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2015 Jack Fagner 3 | 4 | This file is part of OpenTidl. 5 | 6 | OpenTidl is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU Affero General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | OpenTidl is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU Affero General Public License for more details. 15 | 16 | You should have received a copy of the GNU Affero General Public License 17 | along with OpenTidl. If not, see . 18 | */ 19 | using System; 20 | using System.Collections.Generic; 21 | using System.Linq; 22 | using System.Text; 23 | using System.Threading.Tasks; 24 | using OpenTidl.Models.Base; 25 | using System.Runtime.Serialization; 26 | using OpenTidl.Transport; 27 | 28 | namespace OpenTidl.Models 29 | { 30 | [DataContract] 31 | public class ArtistBiographyModel : ModelBase 32 | { 33 | [DataMember(Name = "source")] 34 | public String Source { get; private set; } 35 | 36 | [DataMember(Name = "text")] 37 | public String Text { get; private set; } 38 | 39 | 40 | [DataMember(Name = "summary")] 41 | public String Summary { get; private set; } 42 | 43 | [IgnoreDataMember] 44 | public DateTime? LastUpdated { get; private set; } 45 | 46 | 47 | #region json helpers 48 | 49 | [DataMember(Name = "lastUpdated")] 50 | private String LastUpdatedDateHelper 51 | { 52 | get { return RestUtility.FormatDate(LastUpdated); } 53 | set { LastUpdated = RestUtility.ParseDate(value); } 54 | } 55 | 56 | #endregion 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /OpenTidl/Models/ArtistModel.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2015 Jack Fagner 3 | 4 | This file is part of OpenTidl. 5 | 6 | OpenTidl is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU Affero General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | OpenTidl is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU Affero General Public License for more details. 15 | 16 | You should have received a copy of the GNU Affero General Public License 17 | along with OpenTidl. If not, see . 18 | */ 19 | using System; 20 | using System.Collections.Generic; 21 | using System.Linq; 22 | using System.Text; 23 | using System.Threading.Tasks; 24 | using OpenTidl.Models.Base; 25 | using System.Runtime.Serialization; 26 | 27 | namespace OpenTidl.Models 28 | { 29 | [DataContract] 30 | public class ArtistModel : ModelBase 31 | { 32 | [DataMember(Name = "id")] 33 | public Int32 Id { get; private set; } 34 | 35 | [DataMember(Name = "name")] 36 | public String Name { get; private set; } 37 | 38 | [DataMember(Name = "picture")] 39 | public String Picture { get; private set; } 40 | 41 | [DataMember(Name = "type")] 42 | public String Type { get; private set; } 43 | 44 | 45 | [DataMember(Name = "url")] 46 | public String Url { get; private set; } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /OpenTidl/Models/Base/ErrorModel.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2015 Jack Fagner 3 | 4 | This file is part of OpenTidl. 5 | 6 | OpenTidl is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU Affero General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | OpenTidl is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU Affero General Public License for more details. 15 | 16 | You should have received a copy of the GNU Affero General Public License 17 | along with OpenTidl. If not, see . 18 | */ 19 | using System; 20 | using System.Collections.Generic; 21 | using System.Linq; 22 | using System.Text; 23 | using System.Threading.Tasks; 24 | using System.Runtime.Serialization; 25 | 26 | namespace OpenTidl.Models.Base 27 | { 28 | [DataContract] 29 | public class ErrorModel 30 | { 31 | [DataMember(Name = "status")] 32 | public Int32 Status { get; private set; } 33 | 34 | [DataMember(Name = "subStatus")] 35 | public Int32 SubStatus { get; private set; } 36 | 37 | [DataMember(Name = "userMessage")] 38 | public String UserMessage { get; private set; } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /OpenTidl/Models/Base/JsonList.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2015 Jack Fagner 3 | 4 | This file is part of OpenTidl. 5 | 6 | OpenTidl is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU Affero General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | OpenTidl is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU Affero General Public License for more details. 15 | 16 | You should have received a copy of the GNU Affero General Public License 17 | along with OpenTidl. If not, see . 18 | */ 19 | using System; 20 | using System.Collections.Generic; 21 | using System.Linq; 22 | using System.Text; 23 | using System.Threading.Tasks; 24 | using System.Runtime.Serialization; 25 | 26 | namespace OpenTidl.Models.Base 27 | { 28 | [DataContract] 29 | public class JsonList : ModelBase 30 | { 31 | [DataMember(Name = "limit")] 32 | public Int32 Limit { get; private set; } 33 | 34 | [DataMember(Name = "offset")] 35 | public Int32 Offset { get; private set; } 36 | 37 | [DataMember(Name = "totalNumberOfItems")] 38 | public Int32 TotalNumberOfItems { get; private set; } 39 | 40 | [DataMember(Name = "items")] 41 | public T[] Items { get; private set; } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /OpenTidl/Models/Base/JsonListItem.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2015 Jack Fagner 3 | 4 | This file is part of OpenTidl. 5 | 6 | OpenTidl is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU Affero General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | OpenTidl is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU Affero General Public License for more details. 15 | 16 | You should have received a copy of the GNU Affero General Public License 17 | along with OpenTidl. If not, see . 18 | */ 19 | using System; 20 | using System.Collections.Generic; 21 | using System.Linq; 22 | using System.Text; 23 | using System.Threading.Tasks; 24 | using System.Runtime.Serialization; 25 | using OpenTidl.Transport; 26 | 27 | namespace OpenTidl.Models.Base 28 | { 29 | [DataContract] 30 | public class JsonListItem 31 | { 32 | [IgnoreDataMember] 33 | public DateTime? Created { get; private set; } 34 | 35 | [DataMember(Name = "item")] 36 | public T Item { get; private set; } 37 | 38 | 39 | #region json helpers 40 | 41 | [DataMember(Name = "created")] 42 | private String CreatedDateHelper 43 | { 44 | get { return RestUtility.FormatDate(Created); } 45 | set { Created = RestUtility.ParseDate(value); } 46 | } 47 | 48 | #endregion 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /OpenTidl/Models/Base/ModelArray.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2015 Jack Fagner 3 | 4 | This file is part of OpenTidl. 5 | 6 | OpenTidl is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU Affero General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | OpenTidl is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU Affero General Public License for more details. 15 | 16 | You should have received a copy of the GNU Affero General Public License 17 | along with OpenTidl. If not, see . 18 | */ 19 | using System; 20 | using System.Collections.Generic; 21 | using System.Linq; 22 | using System.Text; 23 | using System.Threading.Tasks; 24 | using System.Runtime.Serialization; 25 | 26 | namespace OpenTidl.Models.Base 27 | { 28 | [DataContract] 29 | public class ModelArray : ModelBase, IList 30 | { 31 | #region fields 32 | 33 | private List _list = new List(); 34 | 35 | #endregion 36 | 37 | 38 | #region IList 39 | 40 | public int IndexOf(T item) 41 | { 42 | return _list.IndexOf(item); 43 | } 44 | 45 | public void Insert(int index, T item) 46 | { 47 | _list.Insert(index, item); 48 | } 49 | 50 | public void RemoveAt(int index) 51 | { 52 | _list.RemoveAt(index); 53 | } 54 | 55 | public T this[int index] 56 | { 57 | get 58 | { 59 | return _list[index]; 60 | } 61 | set 62 | { 63 | _list[index] = value; 64 | } 65 | } 66 | 67 | public void Add(T item) 68 | { 69 | _list.Add(item); 70 | } 71 | 72 | public void Clear() 73 | { 74 | _list.Clear(); 75 | } 76 | 77 | public bool Contains(T item) 78 | { 79 | return _list.Contains(item); 80 | } 81 | 82 | public void CopyTo(T[] array, int arrayIndex) 83 | { 84 | _list.CopyTo(array, arrayIndex); 85 | } 86 | 87 | public int Count 88 | { 89 | get { return _list.Count; } 90 | } 91 | 92 | public bool IsReadOnly 93 | { 94 | get { return false; } 95 | } 96 | 97 | public bool Remove(T item) 98 | { 99 | return _list.Remove(item); 100 | } 101 | 102 | public IEnumerator GetEnumerator() 103 | { 104 | return _list.GetEnumerator(); 105 | } 106 | 107 | System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() 108 | { 109 | return _list.GetEnumerator(); 110 | } 111 | 112 | #endregion 113 | } 114 | } 115 | -------------------------------------------------------------------------------- /OpenTidl/Models/Base/ModelBase.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2015 Jack Fagner 3 | 4 | This file is part of OpenTidl. 5 | 6 | OpenTidl is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU Affero General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | OpenTidl is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU Affero General Public License for more details. 15 | 16 | You should have received a copy of the GNU Affero General Public License 17 | along with OpenTidl. If not, see . 18 | */ 19 | using System; 20 | using System.Collections.Generic; 21 | using System.Linq; 22 | using System.Text; 23 | using System.Threading.Tasks; 24 | using System.Runtime.Serialization; 25 | 26 | namespace OpenTidl.Models.Base 27 | { 28 | [DataContract] 29 | public abstract class ModelBase 30 | { 31 | #region properties 32 | 33 | public String ETag { get; internal set; } 34 | 35 | #endregion 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /OpenTidl/Models/Base/SearchType.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2015 Jack Fagner 3 | 4 | This file is part of OpenTidl. 5 | 6 | OpenTidl is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU Affero General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | OpenTidl is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU Affero General Public License for more details. 15 | 16 | You should have received a copy of the GNU Affero General Public License 17 | along with OpenTidl. If not, see . 18 | */ 19 | using System; 20 | using System.Collections.Generic; 21 | using System.Linq; 22 | using System.Text; 23 | using System.Threading.Tasks; 24 | 25 | namespace OpenTidl.Models.Base 26 | { 27 | public class SearchType 28 | { 29 | #region properties 30 | 31 | public Boolean Albums { get; private set; } 32 | public Boolean Artists { get; private set; } 33 | public Boolean Playlists { get; private set; } 34 | public Boolean Tracks { get; private set; } 35 | public Boolean Videos { get; private set; } 36 | 37 | #endregion 38 | 39 | 40 | #region methods 41 | 42 | public override string ToString() 43 | { 44 | var types = new List(); 45 | if (this.Albums) types.Add("ALBUMS"); 46 | if (this.Artists) types.Add("ARTISTS"); 47 | if (this.Playlists) types.Add("PLAYLISTS"); 48 | if (this.Tracks) types.Add("TRACKS"); 49 | if (this.Videos) types.Add("VIDEOS"); 50 | return String.Join(",", types); 51 | } 52 | 53 | #endregion 54 | 55 | 56 | #region construction 57 | 58 | public static SearchType ALL 59 | { 60 | get 61 | { 62 | return new SearchType(true, true, true, true, true); 63 | } 64 | } 65 | 66 | public static SearchType ALBUMS 67 | { 68 | get 69 | { 70 | return new SearchType(true, false, false, false, false); 71 | } 72 | } 73 | 74 | public static SearchType ARTISTS 75 | { 76 | get 77 | { 78 | return new SearchType(false, true, false, false, false); 79 | } 80 | } 81 | 82 | public static SearchType PLAYLISTS 83 | { 84 | get 85 | { 86 | return new SearchType(false, false, true, false, false); 87 | } 88 | } 89 | 90 | public static SearchType TRACKS 91 | { 92 | get 93 | { 94 | return new SearchType(false, false, false, true, false); 95 | } 96 | } 97 | 98 | public static SearchType VIDEOS 99 | { 100 | get 101 | { 102 | return new SearchType(false, false, false, false, true); 103 | } 104 | } 105 | 106 | public static SearchType Select(Boolean albums, Boolean artists, Boolean playlists, Boolean tracks, Boolean videos) 107 | { 108 | return new SearchType(albums, artists, playlists, tracks, videos); 109 | } 110 | 111 | private SearchType(Boolean albums, Boolean artists, Boolean playlists, Boolean tracks, Boolean videos) 112 | { 113 | this.Albums = albums; 114 | this.Artists = artists; 115 | this.Playlists = playlists; 116 | this.Tracks = tracks; 117 | this.Videos = videos; 118 | } 119 | 120 | #endregion 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /OpenTidl/Models/Base/WebStreamModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using OpenTidl; 7 | using System.IO; 8 | using System.Net; 9 | 10 | namespace OpenTidl.Models.Base 11 | { 12 | public class WebStreamModel 13 | { 14 | #region properties 15 | 16 | public Stream Stream { get; private set; } 17 | public Int64 ContentLength { get; private set; } 18 | 19 | #endregion 20 | 21 | 22 | #region methods 23 | 24 | public Byte[] ToArray() 25 | { 26 | return this.Stream.ToArray(); 27 | } 28 | 29 | #endregion 30 | 31 | 32 | #region construction 33 | 34 | internal WebStreamModel(HttpWebResponse response) 35 | { 36 | try 37 | { 38 | if (response != null) 39 | { 40 | this.ContentLength = response.ContentLength; 41 | this.Stream = response.GetResponseStream(); 42 | } 43 | } 44 | catch { } 45 | } 46 | 47 | #endregion 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /OpenTidl/Models/ClientModel.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2015 Jack Fagner 3 | 4 | This file is part of OpenTidl. 5 | 6 | OpenTidl is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU Affero General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | OpenTidl is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU Affero General Public License for more details. 15 | 16 | You should have received a copy of the GNU Affero General Public License 17 | along with OpenTidl. If not, see . 18 | */ 19 | using System; 20 | using System.Collections.Generic; 21 | using System.Linq; 22 | using System.Text; 23 | using System.Threading.Tasks; 24 | using OpenTidl.Models.Base; 25 | using System.Runtime.Serialization; 26 | using OpenTidl.Transport; 27 | 28 | namespace OpenTidl.Models 29 | { 30 | [DataContract] 31 | public class ClientModel : ModelBase 32 | { 33 | [DataMember(Name = "authorizedForOffline")] 34 | public Boolean AuthorizedForOffline { get; private set; } 35 | 36 | [IgnoreDataMember] 37 | public DateTime? AuthorizedForOfflineDate { get; private set; } 38 | 39 | [IgnoreDataMember] 40 | public DateTime? Created { get; private set; } 41 | 42 | [DataMember(Name = "id")] 43 | public Int32 Id { get; private set; } 44 | 45 | [IgnoreDataMember] 46 | public DateTime? LastLogin { get; private set; } 47 | 48 | [DataMember(Name = "name")] 49 | public String Name { get; private set; } 50 | 51 | [DataMember(Name = "numberOfOfflineAlbums")] 52 | public Int32 NumberOfOfflineAlbums { get; private set; } 53 | 54 | [DataMember(Name = "numberOfOfflinePlaylists")] 55 | public Int32 NumberOfOfflinePlaylists { get; private set; } 56 | 57 | [DataMember(Name = "uniqueKey")] 58 | public String UniqueKey { get; private set; } 59 | 60 | [DataMember(Name = "application")] 61 | public ApplicationModel Application { get; private set; } 62 | 63 | 64 | #region json helpers 65 | 66 | [DataMember(Name = "authorizedForOfflineDate")] 67 | private String AuthorizedForOfflineDateHelper 68 | { 69 | get { return RestUtility.FormatDate(AuthorizedForOfflineDate); } 70 | set { AuthorizedForOfflineDate = RestUtility.ParseDate(value); } 71 | } 72 | 73 | [DataMember(Name = "created")] 74 | private String CreatedDateHelper 75 | { 76 | get { return RestUtility.FormatDate(Created); } 77 | set { Created = RestUtility.ParseDate(value); } 78 | } 79 | 80 | [DataMember(Name = "lastLogin")] 81 | private String LastLoginDateHelper 82 | { 83 | get { return RestUtility.FormatDate(LastLogin); } 84 | set { LastLogin = RestUtility.ParseDate(value); } 85 | } 86 | 87 | #endregion 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /OpenTidl/Models/ContributorModel.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2015 Jack Fagner 3 | 4 | This file is part of OpenTidl. 5 | 6 | OpenTidl is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU Affero General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | OpenTidl is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU Affero General Public License for more details. 15 | 16 | You should have received a copy of the GNU Affero General Public License 17 | along with OpenTidl. If not, see . 18 | */ 19 | using System; 20 | using System.Collections.Generic; 21 | using System.Linq; 22 | using System.Text; 23 | using System.Threading.Tasks; 24 | using OpenTidl.Models.Base; 25 | using OpenTidl.Enums; 26 | using System.Runtime.Serialization; 27 | using OpenTidl.Transport; 28 | 29 | namespace OpenTidl.Models 30 | { 31 | [DataContract] 32 | public class ContributorModel : ModelBase 33 | { 34 | [DataMember(Name = "name")] 35 | public String Name { get; private set; } 36 | 37 | [IgnoreDataMember] 38 | public ContributorRole Role { get; private set; } 39 | 40 | 41 | #region enum helpers 42 | 43 | [DataMember(Name = "role")] 44 | private String RoleEnumHelper 45 | { 46 | get { return Role.ToString(); } 47 | set { Role = RestUtility.ParseEnum(value); } 48 | } 49 | 50 | #endregion 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /OpenTidl/Models/CountryModel.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2015 Jack Fagner 3 | 4 | This file is part of OpenTidl. 5 | 6 | OpenTidl is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU Affero General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | OpenTidl is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU Affero General Public License for more details. 15 | 16 | You should have received a copy of the GNU Affero General Public License 17 | along with OpenTidl. If not, see . 18 | */ 19 | using System; 20 | using System.Collections.Generic; 21 | using System.Linq; 22 | using System.Text; 23 | using System.Threading.Tasks; 24 | using OpenTidl.Models.Base; 25 | using System.Runtime.Serialization; 26 | 27 | namespace OpenTidl.Models 28 | { 29 | [DataContract] 30 | public class CountryModel : ModelBase 31 | { 32 | [DataMember(Name = "countryCode")] 33 | public String CountryCode { get; private set; } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /OpenTidl/Models/CreatorModel.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2015 Jack Fagner 3 | 4 | This file is part of OpenTidl. 5 | 6 | OpenTidl is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU Affero General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | OpenTidl is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU Affero General Public License for more details. 15 | 16 | You should have received a copy of the GNU Affero General Public License 17 | along with OpenTidl. If not, see . 18 | */ 19 | using System; 20 | using System.Collections.Generic; 21 | using System.Linq; 22 | using System.Text; 23 | using System.Threading.Tasks; 24 | using OpenTidl.Models.Base; 25 | using System.Runtime.Serialization; 26 | 27 | namespace OpenTidl.Models 28 | { 29 | [DataContract] 30 | public class CreatorModel : ModelBase 31 | { 32 | [DataMember(Name = "id")] 33 | public Int32 Id { get; private set; } 34 | 35 | [DataMember(Name = "name")] 36 | public String Name { get; private set; } 37 | 38 | 39 | 40 | [DataMember(Name = "child")] 41 | public Boolean Child { get; private set; } 42 | 43 | [DataMember(Name = "parent")] 44 | public Boolean Parent { get; private set; } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /OpenTidl/Models/EmptyModel.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2015 Jack Fagner 3 | 4 | This file is part of OpenTidl. 5 | 6 | OpenTidl is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU Affero General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | OpenTidl is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU Affero General Public License for more details. 15 | 16 | You should have received a copy of the GNU Affero General Public License 17 | along with OpenTidl. If not, see . 18 | */ 19 | using System; 20 | using System.Collections.Generic; 21 | using System.Linq; 22 | using System.Text; 23 | using System.Threading.Tasks; 24 | using OpenTidl.Models.Base; 25 | using System.Runtime.Serialization; 26 | 27 | namespace OpenTidl.Models 28 | { 29 | [DataContract] 30 | public class EmptyModel : ModelBase 31 | { 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /OpenTidl/Models/LinkModel.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2015 Jack Fagner 3 | 4 | This file is part of OpenTidl. 5 | 6 | OpenTidl is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU Affero General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | OpenTidl is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU Affero General Public License for more details. 15 | 16 | You should have received a copy of the GNU Affero General Public License 17 | along with OpenTidl. If not, see . 18 | */ 19 | using System; 20 | using System.Collections.Generic; 21 | using System.Linq; 22 | using System.Text; 23 | using System.Threading.Tasks; 24 | using OpenTidl.Models.Base; 25 | using System.Runtime.Serialization; 26 | 27 | namespace OpenTidl.Models 28 | { 29 | [DataContract] 30 | public class LinkModel : ModelBase 31 | { 32 | [DataMember(Name = "siteName")] 33 | public String SiteName { get; private set; } 34 | 35 | [DataMember(Name = "url")] 36 | public String Url { get; private set; } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /OpenTidl/Models/LoginModel.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2015 Jack Fagner 3 | 4 | This file is part of OpenTidl. 5 | 6 | OpenTidl is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU Affero General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | OpenTidl is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU Affero General Public License for more details. 15 | 16 | You should have received a copy of the GNU Affero General Public License 17 | along with OpenTidl. If not, see . 18 | */ 19 | using System; 20 | using System.Collections.Generic; 21 | using System.Linq; 22 | using System.Text; 23 | using System.Threading.Tasks; 24 | using OpenTidl.Models.Base; 25 | using OpenTidl.Enums; 26 | using System.Runtime.Serialization; 27 | 28 | namespace OpenTidl.Models 29 | { 30 | [DataContract] 31 | public class LoginModel : ModelBase 32 | { 33 | [DataMember(Name = "countryCode")] 34 | public String CountryCode { get; private set; } 35 | 36 | [DataMember(Name = "sessionId")] 37 | public String SessionId { get; private set; } 38 | 39 | [DataMember(Name = "userId")] 40 | public Int32 UserId { get; private set; } 41 | 42 | [IgnoreDataMember] 43 | public LoginType LoginType { get; internal set; } 44 | 45 | 46 | internal static LoginModel FromSession(SessionModel session) 47 | { 48 | return new LoginModel() 49 | { 50 | CountryCode = session.CountryCode, 51 | SessionId = session.SessionId, 52 | UserId = session.UserId, 53 | LoginType = LoginType.Unknown 54 | }; 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /OpenTidl/Models/PlaylistModel.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2015 Jack Fagner 3 | 4 | This file is part of OpenTidl. 5 | 6 | OpenTidl is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU Affero General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | OpenTidl is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU Affero General Public License for more details. 15 | 16 | You should have received a copy of the GNU Affero General Public License 17 | along with OpenTidl. If not, see . 18 | */ 19 | using System; 20 | using System.Collections.Generic; 21 | using System.Linq; 22 | using System.Text; 23 | using System.Threading.Tasks; 24 | using OpenTidl.Enums; 25 | using OpenTidl.Models.Base; 26 | using System.Runtime.Serialization; 27 | using OpenTidl.Transport; 28 | 29 | namespace OpenTidl.Models 30 | { 31 | [DataContract] 32 | public class PlaylistModel : ModelBase 33 | { 34 | [IgnoreDataMember] 35 | public DateTime? Created { get; private set; } 36 | 37 | [DataMember(Name = "creator")] 38 | public CreatorModel Creator { get; private set; } 39 | 40 | [DataMember(Name = "description")] 41 | public String Description { get; private set; } 42 | 43 | [DataMember(Name = "duration")] 44 | public Int32 Duration { get; private set; } 45 | 46 | [DataMember(Name = "image")] 47 | public String Image { get; private set; } 48 | 49 | [IgnoreDataMember] 50 | public DateTime? LastUpdated { get; private set; } 51 | 52 | [DataMember(Name = "numberOfTracks")] 53 | public Int32 NumberOfTracks { get; private set; } 54 | 55 | [DataMember(Name = "offlineDateAdded")] 56 | public Int64 OfflineDateAdded { get; private set; } 57 | 58 | [DataMember(Name = "title")] 59 | public String Title { get; private set; } 60 | 61 | [IgnoreDataMember] 62 | public PlaylistType Type { get; private set; } 63 | 64 | [DataMember(Name = "uuid")] 65 | public String Uuid { get; private set; } 66 | 67 | 68 | 69 | [DataMember(Name = "url")] 70 | public String Url { get; private set; } 71 | 72 | [DataMember(Name = "publicPlaylist")] 73 | public Boolean PublicPlaylist { get; private set; } 74 | 75 | 76 | #region json helpers 77 | 78 | [DataMember(Name = "type")] 79 | private String TypeEnumHelper 80 | { 81 | get { return Type.ToString(); } 82 | set { Type = RestUtility.ParseEnum(value); } 83 | } 84 | 85 | [DataMember(Name = "created")] 86 | private String CreatedDateHelper 87 | { 88 | get { return RestUtility.FormatDate(Created); } 89 | set { Created = RestUtility.ParseDate(value); } 90 | } 91 | 92 | [DataMember(Name = "lastUpdated")] 93 | private String LastUpdatedDateHelper 94 | { 95 | get { return RestUtility.FormatDate(LastUpdated); } 96 | set { LastUpdated = RestUtility.ParseDate(value); } 97 | } 98 | 99 | #endregion 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /OpenTidl/Models/RecoverPasswordResponseModel.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2015 Jack Fagner 3 | 4 | This file is part of OpenTidl. 5 | 6 | OpenTidl is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU Affero General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | OpenTidl is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU Affero General Public License for more details. 15 | 16 | You should have received a copy of the GNU Affero General Public License 17 | along with OpenTidl. If not, see . 18 | */ 19 | using System; 20 | using System.Collections.Generic; 21 | using System.Linq; 22 | using System.Text; 23 | using System.Threading.Tasks; 24 | using OpenTidl.Models.Base; 25 | using System.Runtime.Serialization; 26 | 27 | namespace OpenTidl.Models 28 | { 29 | [DataContract] 30 | public class RecoverPasswordResponseModel : ModelBase 31 | { 32 | [DataMember(Name = "communicationChannel")] 33 | public String CommunicationChannel { get; private set; } 34 | 35 | [DataMember(Name = "responseStatus")] 36 | public String ResponseStatus { get; private set; } 37 | 38 | [DataMember(Name = "statusMessage")] 39 | public String StatusMessage { get; private set; } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /OpenTidl/Models/SearchResultModel.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2015 Jack Fagner 3 | 4 | This file is part of OpenTidl. 5 | 6 | OpenTidl is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU Affero General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | OpenTidl is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU Affero General Public License for more details. 15 | 16 | You should have received a copy of the GNU Affero General Public License 17 | along with OpenTidl. If not, see . 18 | */ 19 | using System; 20 | using System.Collections.Generic; 21 | using System.Linq; 22 | using System.Text; 23 | using System.Threading.Tasks; 24 | using OpenTidl.Models.Base; 25 | using System.Runtime.Serialization; 26 | 27 | namespace OpenTidl.Models 28 | { 29 | [DataContract] 30 | public class SearchResultModel : ModelBase 31 | { 32 | [DataMember(Name = "albums")] 33 | public JsonList Albums { get; private set; } 34 | 35 | [DataMember(Name = "artists")] 36 | public JsonList Artists { get; private set; } 37 | 38 | [DataMember(Name = "playlists")] 39 | public JsonList Playlists { get; private set; } 40 | 41 | [DataMember(Name = "tracks")] 42 | public JsonList Tracks { get; private set; } 43 | 44 | [DataMember(Name = "videos")] 45 | public JsonList Videos { get; private set; } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /OpenTidl/Models/SessionModel.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2015 Jack Fagner 3 | 4 | This file is part of OpenTidl. 5 | 6 | OpenTidl is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU Affero General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | OpenTidl is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU Affero General Public License for more details. 15 | 16 | You should have received a copy of the GNU Affero General Public License 17 | along with OpenTidl. If not, see . 18 | */ 19 | using System; 20 | using System.Collections.Generic; 21 | using System.Linq; 22 | using System.Text; 23 | using System.Threading.Tasks; 24 | using OpenTidl.Models.Base; 25 | using System.Runtime.Serialization; 26 | 27 | namespace OpenTidl.Models 28 | { 29 | [DataContract] 30 | public class SessionModel : ModelBase 31 | { 32 | [DataMember(Name = "channelId")] 33 | public Int32 ChannelId { get; private set; } 34 | 35 | [DataMember(Name = "client")] 36 | public ClientModel Client { get; private set; } 37 | 38 | [DataMember(Name = "countryCode")] 39 | public String CountryCode { get; private set; } 40 | 41 | [DataMember(Name = "partnerId")] 42 | public Int32 PartnerId { get; private set; } 43 | 44 | [DataMember(Name = "sessionId")] 45 | public String SessionId { get; private set; } 46 | 47 | [DataMember(Name = "userId")] 48 | public Int32 UserId { get; private set; } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /OpenTidl/Models/StreamUrlModel.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2015 Jack Fagner 3 | 4 | This file is part of OpenTidl. 5 | 6 | OpenTidl is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU Affero General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | OpenTidl is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU Affero General Public License for more details. 15 | 16 | You should have received a copy of the GNU Affero General Public License 17 | along with OpenTidl. If not, see . 18 | */ 19 | using System; 20 | using System.Collections.Generic; 21 | using System.Linq; 22 | using System.Text; 23 | using System.Threading.Tasks; 24 | using OpenTidl.Models.Base; 25 | using OpenTidl.Enums; 26 | using System.Runtime.Serialization; 27 | using OpenTidl.Transport; 28 | 29 | namespace OpenTidl.Models 30 | { 31 | [DataContract] 32 | public class StreamUrlModel : ModelBase 33 | { 34 | [DataMember(Name = "playTimeLeftInMinutes")] 35 | public Int32 PlayTimeLeftInMinutes { get; private set; } 36 | 37 | [IgnoreDataMember] 38 | public SoundQuality SoundQuality { get; private set; } 39 | 40 | [IgnoreDataMember] 41 | public StreamResponseType StreamResponseType { get; private set; } 42 | 43 | [IgnoreDataMember] 44 | public StreamSource StreamSource { get; private set; } 45 | 46 | [DataMember(Name = "trackId")] 47 | public Int32 TrackId { get; private set; } 48 | 49 | [DataMember(Name = "url")] 50 | public String Url { get; private set; } 51 | 52 | 53 | #region enum helpers 54 | 55 | [DataMember(Name = "soundQuality")] 56 | private String RoleEnumHelper 57 | { 58 | get { return SoundQuality.ToString(); } 59 | set { SoundQuality = RestUtility.ParseEnum(value); } 60 | } 61 | 62 | [DataMember(Name = "streamResponseType")] 63 | private String StreamResponseTypeEnumHelper 64 | { 65 | get { return StreamResponseType.ToString(); } 66 | set { StreamResponseType = RestUtility.ParseEnum(value); } 67 | } 68 | 69 | [DataMember(Name = "streamSource")] 70 | private String StreamSourceEnumHelper 71 | { 72 | get { return StreamSource.ToString(); } 73 | set { StreamSource = RestUtility.ParseEnum(value); } 74 | } 75 | 76 | #endregion 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /OpenTidl/Models/SubscriptionModel.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2015 Jack Fagner 3 | 4 | This file is part of OpenTidl. 5 | 6 | OpenTidl is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU Affero General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | OpenTidl is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU Affero General Public License for more details. 15 | 16 | You should have received a copy of the GNU Affero General Public License 17 | along with OpenTidl. If not, see . 18 | */ 19 | using System; 20 | using System.Collections.Generic; 21 | using System.Linq; 22 | using System.Text; 23 | using System.Threading.Tasks; 24 | using OpenTidl.Models.Base; 25 | using OpenTidl.Enums; 26 | using System.Runtime.Serialization; 27 | using OpenTidl.Transport; 28 | 29 | namespace OpenTidl.Models 30 | { 31 | [DataContract] 32 | public class SubscriptionModel : ModelBase 33 | { 34 | [DataMember(Name = "daysInPeriod")] 35 | public Int32 DaysInPeriod { get; private set; } 36 | 37 | [DataMember(Name = "id")] 38 | public Int32 Id { get; private set; } 39 | 40 | [DataMember(Name = "name")] 41 | public String Name { get; private set; } 42 | 43 | [DataMember(Name = "price")] 44 | public Int32 Price { get; private set; } 45 | 46 | [DataMember(Name = "offlineGracePeriod")] 47 | public Int32 OfflineGracePeriod { get; private set; } 48 | 49 | [IgnoreDataMember] 50 | public SubscriptionType Type { get; private set; } 51 | 52 | 53 | #region enum helpers 54 | 55 | [DataMember(Name = "type")] 56 | private String TypeEnumHelper 57 | { 58 | get { return Type.ToString(); } 59 | set { Type = RestUtility.ParseEnum(value); } 60 | } 61 | 62 | #endregion 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /OpenTidl/Models/TrackModel.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2015 Jack Fagner 3 | 4 | This file is part of OpenTidl. 5 | 6 | OpenTidl is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU Affero General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | OpenTidl is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU Affero General Public License for more details. 15 | 16 | You should have received a copy of the GNU Affero General Public License 17 | along with OpenTidl. If not, see . 18 | */ 19 | using System; 20 | using System.Collections.Generic; 21 | using System.Linq; 22 | using System.Text; 23 | using System.Threading.Tasks; 24 | using OpenTidl.Models.Base; 25 | using System.Runtime.Serialization; 26 | using OpenTidl.Transport; 27 | 28 | namespace OpenTidl.Models 29 | { 30 | [DataContract] 31 | public class TrackModel : ModelBase 32 | { 33 | [DataMember(Name = "album")] 34 | public AlbumModel Album { get; private set; } 35 | 36 | [DataMember(Name = "allowStreaming")] 37 | public Boolean AllowStreaming { get; private set; } 38 | 39 | [DataMember(Name = "artist")] 40 | public ArtistModel Artist { get; private set; } 41 | 42 | [DataMember(Name = "artists")] 43 | public ArtistModel[] Artists { get; private set; } 44 | 45 | [DataMember(Name = "duration")] 46 | public Int32 Duration { get; private set; } 47 | 48 | [DataMember(Name = "id")] 49 | public Int32 Id { get; private set; } 50 | 51 | [DataMember(Name = "streamReady")] 52 | public Boolean StreamReady { get; private set; } 53 | 54 | [IgnoreDataMember] 55 | public DateTime? StreamStartDate { get; private set; } 56 | 57 | [DataMember(Name = "title")] 58 | public String Title { get; private set; } 59 | 60 | [DataMember(Name = "trackNumber")] 61 | public Int32 TrackNumber { get; private set; } 62 | 63 | [DataMember(Name = "version")] 64 | public String Version { get; private set; } 65 | 66 | [DataMember(Name = "volumeNumber")] 67 | public Int32 VolumeNumber { get; private set; } 68 | 69 | 70 | [DataMember(Name = "url")] 71 | public String Url { get; private set; } 72 | 73 | [DataMember(Name = "premiumStreamingOnly")] 74 | public Boolean PremiumStreamingOnly { get; private set; } 75 | 76 | [DataMember(Name = "popularity")] 77 | public Int32 Popularity { get; private set; } 78 | 79 | [DataMember(Name = "copyright")] 80 | public String Copyright { get; private set; } 81 | 82 | [DataMember(Name = "isrc")] 83 | public String Isrc { get; private set; } 84 | 85 | [DataMember(Name = "audioQuality")] 86 | public String AudioQuality { get; private set; } 87 | 88 | #region json helpers 89 | 90 | [DataMember(Name = "streamStartDate")] 91 | private String StreamStartDateHelper 92 | { 93 | get { return RestUtility.FormatDate(StreamStartDate); } 94 | set { StreamStartDate = RestUtility.ParseDate(value); } 95 | } 96 | 97 | #endregion 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /OpenTidl/Models/UserModel.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2015 Jack Fagner 3 | 4 | This file is part of OpenTidl. 5 | 6 | OpenTidl is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU Affero General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | OpenTidl is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU Affero General Public License for more details. 15 | 16 | You should have received a copy of the GNU Affero General Public License 17 | along with OpenTidl. If not, see . 18 | */ 19 | using System; 20 | using System.Collections.Generic; 21 | using System.Linq; 22 | using System.Text; 23 | using System.Threading.Tasks; 24 | using OpenTidl.Models.Base; 25 | using System.Runtime.Serialization; 26 | using OpenTidl.Enums; 27 | using OpenTidl.Transport; 28 | 29 | namespace OpenTidl.Models 30 | { 31 | [DataContract] 32 | public class UserModel : ModelBase 33 | { 34 | [IgnoreDataMember] 35 | public DateTime? DateOfBirth { get; private set; } 36 | 37 | [DataMember(Name = "email")] 38 | public String Email { get; private set; } 39 | 40 | [DataMember(Name = "facebookUid")] 41 | public Int64 FacebookUid { get; private set; } 42 | 43 | [DataMember(Name = "firstName")] 44 | public String FirstName { get; private set; } 45 | 46 | [IgnoreDataMember] 47 | public UserGender Gender { get; private set; } 48 | 49 | [DataMember(Name = "id")] 50 | public Int64 Id { get; private set; } 51 | 52 | [DataMember(Name = "lastName")] 53 | public String LastName { get; private set; } 54 | 55 | [DataMember(Name = "newsletter")] 56 | public Boolean Newsletter { get; private set; } 57 | 58 | [DataMember(Name = "picture")] 59 | public String Picture { get; private set; } 60 | 61 | [DataMember(Name = "username")] 62 | public String Username { get; private set; } 63 | 64 | 65 | #region json helpers 66 | 67 | [DataMember(Name = "gender")] 68 | private String GenderEnumHelper 69 | { 70 | get { return Gender.ToString().Substring(0, 1).ToLower(); } 71 | set 72 | { 73 | switch ((value ?? "").ToLower()) 74 | { 75 | case "f": 76 | Gender = UserGender.Female; 77 | break; 78 | case "m": 79 | Gender = UserGender.Male; 80 | break; 81 | default: 82 | Gender = UserGender.NotSpecified; 83 | break; 84 | } 85 | } 86 | } 87 | 88 | [DataMember(Name = "dateOfBirth")] 89 | private String DateOfBirthHelper 90 | { 91 | get { return RestUtility.FormatDate(DateOfBirth); } 92 | set { DateOfBirth = RestUtility.ParseDate(value); } 93 | } 94 | 95 | #endregion 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /OpenTidl/Models/UserSubscriptionModel.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2015 Jack Fagner 3 | 4 | This file is part of OpenTidl. 5 | 6 | OpenTidl is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU Affero General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | OpenTidl is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU Affero General Public License for more details. 15 | 16 | You should have received a copy of the GNU Affero General Public License 17 | along with OpenTidl. If not, see . 18 | */ 19 | using System; 20 | using System.Collections.Generic; 21 | using System.Linq; 22 | using System.Text; 23 | using System.Threading.Tasks; 24 | using OpenTidl.Models.Base; 25 | using OpenTidl.Enums; 26 | using System.Runtime.Serialization; 27 | using OpenTidl.Transport; 28 | 29 | namespace OpenTidl.Models 30 | { 31 | [DataContract] 32 | public class UserSubscriptionModel : ModelBase 33 | { 34 | [IgnoreDataMember] 35 | public SoundQuality HighestSoundQuality { get; private set; } 36 | 37 | [DataMember(Name = "status")] 38 | public String Status { get; private set; } 39 | 40 | [DataMember(Name = "subscription")] 41 | public SubscriptionModel Subscription { get; private set; } 42 | 43 | [IgnoreDataMember] 44 | public DateTime? ValidUntil { get; private set; } 45 | 46 | 47 | [DataMember(Name = "premiumAccess")] 48 | public Boolean PremiumAccess { get; private set; } 49 | 50 | [DataMember(Name = "canGetTrial")] 51 | public Boolean CanGetTrial { get; private set; } 52 | 53 | 54 | [IgnoreDataMember] 55 | public Boolean IsBasicSubscription 56 | { 57 | get { return this.Subscription != null && this.Subscription.Type == SubscriptionType.BASIC; } 58 | } 59 | 60 | [IgnoreDataMember] 61 | public Boolean IsFreeSubscription 62 | { 63 | get { return this.Subscription != null && this.Subscription.Type == SubscriptionType.FREE; } 64 | } 65 | 66 | [IgnoreDataMember] 67 | public Boolean IsHifiAvailable 68 | { 69 | get { return (Int32)this.HighestSoundQuality >= (Int32)SoundQuality.LOSSLESS; } 70 | } 71 | 72 | 73 | #region json helpers 74 | 75 | [DataMember(Name = "highestSoundQuality")] 76 | private String HighestSoundQualityEnumHelper 77 | { 78 | get { return HighestSoundQuality.ToString(); } 79 | set { HighestSoundQuality = RestUtility.ParseEnum(value); } 80 | } 81 | 82 | [DataMember(Name = "validUntil")] 83 | private String ValidUntilDateHelper 84 | { 85 | get { return RestUtility.FormatDate(ValidUntil); } 86 | set { ValidUntil = RestUtility.ParseDate(value); } 87 | } 88 | 89 | #endregion 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /OpenTidl/Models/VideoModel.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2015 Jack Fagner 3 | 4 | This file is part of OpenTidl. 5 | 6 | OpenTidl is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU Affero General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | OpenTidl is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU Affero General Public License for more details. 15 | 16 | You should have received a copy of the GNU Affero General Public License 17 | along with OpenTidl. If not, see . 18 | */ 19 | using System; 20 | using System.Collections.Generic; 21 | using System.Linq; 22 | using System.Text; 23 | using System.Threading.Tasks; 24 | using OpenTidl.Models.Base; 25 | using OpenTidl.Enums; 26 | using System.Runtime.Serialization; 27 | using OpenTidl.Transport; 28 | 29 | namespace OpenTidl.Models 30 | { 31 | [DataContract] 32 | public class VideoModel : ModelBase 33 | { 34 | [DataMember(Name = "artist")] 35 | public ArtistModel Artist { get; private set; } 36 | 37 | [DataMember(Name = "artists")] 38 | public ArtistModel[] Artists { get; private set; } 39 | 40 | [DataMember(Name = "duration")] 41 | public Int32 Duration { get; private set; } 42 | 43 | [DataMember(Name = "id")] 44 | public Int32 Id { get; private set; } 45 | 46 | [DataMember(Name = "imageId")] 47 | public String ImageId { get; private set; } 48 | 49 | [DataMember(Name = "imagePath")] 50 | public String ImagePath { get; private set; } 51 | 52 | [IgnoreDataMember] 53 | public VideoQuality Quality { get; private set; } 54 | 55 | [IgnoreDataMember] 56 | public DateTime? ReleaseDate { get; private set; } 57 | 58 | [DataMember(Name = "streamReady")] 59 | public Boolean StreamReady { get; private set; } 60 | 61 | [IgnoreDataMember] 62 | public DateTime? StreamStartDate { get; private set; } 63 | 64 | [DataMember(Name = "title")] 65 | public String Title { get; private set; } 66 | 67 | 68 | #region json helpers 69 | 70 | [DataMember(Name = "quality")] 71 | private String QualityEnumHelper 72 | { 73 | get { return Quality.ToString(); } 74 | set { Quality = RestUtility.ParseEnum(value); } 75 | } 76 | 77 | [DataMember(Name = "releaseDate")] 78 | private String ReleaseDateHelper 79 | { 80 | get { return RestUtility.FormatDate(ReleaseDate); } 81 | set { ReleaseDate = RestUtility.ParseDate(value); } 82 | } 83 | 84 | [DataMember(Name = "streamStartDate")] 85 | private String StreamStartDateHelper 86 | { 87 | get { return RestUtility.FormatDate(StreamStartDate); } 88 | set { StreamStartDate = RestUtility.ParseDate(value); } 89 | } 90 | 91 | #endregion 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /OpenTidl/Models/VideoStreamUrlModel.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2015 Jack Fagner 3 | 4 | This file is part of OpenTidl. 5 | 6 | OpenTidl is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU Affero General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | OpenTidl is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU Affero General Public License for more details. 15 | 16 | You should have received a copy of the GNU Affero General Public License 17 | along with OpenTidl. If not, see . 18 | */ 19 | using System; 20 | using System.Collections.Generic; 21 | using System.Linq; 22 | using System.Text; 23 | using System.Threading.Tasks; 24 | using OpenTidl.Models.Base; 25 | using OpenTidl.Enums; 26 | using System.Runtime.Serialization; 27 | using OpenTidl.Transport; 28 | 29 | namespace OpenTidl.Models 30 | { 31 | [DataContract] 32 | public class VideoStreamUrlModel : ModelBase 33 | { 34 | /*[IgnoreDataMember] 35 | public VideoQuality VideoQuality { get; private set; }*/ 36 | 37 | [DataMember(Name = "url")] 38 | public String Url { get; private set; } 39 | 40 | 41 | #region enum helpers 42 | 43 | /*[DataMember(Name = "videoQuality")] 44 | private String VideoQualityEnumHelper 45 | { 46 | get { return VideoQuality.ToString(); } 47 | set { VideoQuality = RestUtility.ParseEnum(value); } 48 | }*/ 49 | 50 | #endregion 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /OpenTidl/OpenTidl.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {3796564B-3A91-4AEE-B859-E7E6BCF1521D} 8 | Library 9 | Properties 10 | OpenTidl 11 | OpenTidl 12 | v4.5 13 | 512 14 | 15 | 16 | 17 | 18 | true 19 | full 20 | false 21 | bin\Debug\ 22 | DEBUG;TRACE 23 | prompt 24 | 4 25 | false 26 | 27 | 28 | pdbonly 29 | true 30 | bin\Release\ 31 | TRACE 32 | prompt 33 | 4 34 | false 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | Always 113 | 114 | 115 | 116 | 117 | 118 | 119 | 126 | -------------------------------------------------------------------------------- /OpenTidl/OpenTidl.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | $id$ 5 | $version$ 6 | $title$ 7 | jackfagner 8 | jackfagner 9 | https://raw.githubusercontent.com/jackfagner/OpenTidl/master/LICENSE 10 | https://github.com/jackfagner/OpenTidl 11 | false 12 | $description$ 13 | Copyright 2016 Jack Fagner 14 | tidal opentidal opentidl wimp 15 | 16 | -------------------------------------------------------------------------------- /OpenTidl/OpenTidlClient.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2015 Jack Fagner 3 | 4 | This file is part of OpenTidl. 5 | 6 | OpenTidl is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU Affero General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | OpenTidl is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU Affero General Public License for more details. 15 | 16 | You should have received a copy of the GNU Affero General Public License 17 | along with OpenTidl. If not, see . 18 | */ 19 | using System; 20 | using System.Collections.Generic; 21 | using System.Linq; 22 | using System.Text; 23 | using System.Threading.Tasks; 24 | using OpenTidl.Transport; 25 | using System.IO; 26 | using OpenTidl.Models.Base; 27 | using OpenTidl.Models; 28 | using OpenTidl.Methods; 29 | using OpenTidl.Enums; 30 | using System.Net; 31 | 32 | namespace OpenTidl 33 | { 34 | public partial class OpenTidlClient 35 | { 36 | #region fields 37 | 38 | private const String FALLBACK_COUNTRY_CODE = "US"; 39 | private Lazy _defaultCountryCode; 40 | 41 | #endregion 42 | 43 | 44 | #region properties 45 | 46 | public ClientConfiguration Configuration { get; private set; } 47 | private RestClient RestClient { get; set; } 48 | 49 | private String LastSessionCountryCode { get; set; } 50 | private String DefaultCountryCode { get { return _defaultCountryCode.Value; } } 51 | 52 | #endregion 53 | 54 | 55 | #region methods 56 | 57 | internal KeyValuePair Header(String header, String value) 58 | { 59 | return new KeyValuePair(header, value); 60 | } 61 | 62 | internal T HandleResponse(RestResponse response) where T : ModelBase 63 | { 64 | if (response.Exception != null) 65 | throw response.Exception; 66 | return response.Model; 67 | } 68 | 69 | private LoginModel HandleLoginResponse(RestResponse response, LoginType loginType) 70 | { 71 | if (response.Exception != null) 72 | throw response.Exception; 73 | var model = response.Model; 74 | if (model != null) 75 | { 76 | this.LastSessionCountryCode = model.CountryCode; 77 | model.LoginType = loginType; 78 | } 79 | return model; 80 | } 81 | 82 | private SessionModel HandleSessionResponse(RestResponse response) 83 | { 84 | if (response.Exception != null) 85 | throw response.Exception; 86 | var model = response.Model; 87 | if (model != null) 88 | this.LastSessionCountryCode = model.CountryCode; 89 | return model; 90 | } 91 | 92 | private String GetCountryCode() 93 | { 94 | return !String.IsNullOrEmpty(LastSessionCountryCode) ? LastSessionCountryCode : DefaultCountryCode; 95 | } 96 | 97 | private String GetDefaultCountryCode() 98 | { 99 | CountryModel cc = null; 100 | try 101 | { 102 | cc = this.GetCountry(1000); 103 | } 104 | catch { } 105 | if (cc != null && !String.IsNullOrEmpty(cc.CountryCode)) 106 | return cc.CountryCode; 107 | if (Configuration != null && !String.IsNullOrEmpty(Configuration.DefaultCountryCode)) 108 | return Configuration.DefaultCountryCode; 109 | return FALLBACK_COUNTRY_CODE; 110 | } 111 | 112 | #endregion 113 | 114 | 115 | #region construction 116 | 117 | public OpenTidlClient(ClientConfiguration config) 118 | { 119 | this.Configuration = config; 120 | this.RestClient = new RestClient(config.ApiEndpoint, config.UserAgent, Header("X-Tidal-Token", config.Token)); 121 | this._defaultCountryCode = new Lazy(() => GetDefaultCountryCode()); 122 | } 123 | 124 | #endregion 125 | } 126 | } 127 | -------------------------------------------------------------------------------- /OpenTidl/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("OpenTidl")] 9 | [assembly: AssemblyDescription("Unofficial API for Tidal")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("OpenTidl")] 13 | [assembly: AssemblyCopyright("Copyright © 2016 Jack Fagner")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("1534c6d1-33a7-4a0a-bb9f-ee1887d4337e")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.12.2.0")] 36 | [assembly: AssemblyFileVersion("1.12.2.0")] 37 | -------------------------------------------------------------------------------- /OpenTidl/Transport/OpenTidlException.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2015 Jack Fagner 3 | 4 | This file is part of OpenTidl. 5 | 6 | OpenTidl is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU Affero General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | OpenTidl is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU Affero General Public License for more details. 15 | 16 | You should have received a copy of the GNU Affero General Public License 17 | along with OpenTidl. If not, see . 18 | */ 19 | using System; 20 | using System.Collections.Generic; 21 | using System.Linq; 22 | using System.Text; 23 | using System.Threading.Tasks; 24 | using OpenTidl.Models.Base; 25 | 26 | namespace OpenTidl.Transport 27 | { 28 | public class OpenTidlException : Exception 29 | { 30 | #region properties 31 | 32 | public ErrorModel OpenTidlError { get; private set; } 33 | 34 | #endregion 35 | 36 | 37 | #region construction 38 | 39 | internal OpenTidlException(ErrorModel error) : base((error ?? new ErrorModel()).UserMessage ?? "") 40 | { 41 | this.OpenTidlError = error; 42 | } 43 | 44 | #endregion 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /OpenTidl/Transport/RestClient.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2015 Jack Fagner 3 | 4 | This file is part of OpenTidl. 5 | 6 | OpenTidl is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU Affero General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | OpenTidl is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU Affero General Public License for more details. 15 | 16 | You should have received a copy of the GNU Affero General Public License 17 | along with OpenTidl. If not, see . 18 | */ 19 | using System; 20 | using System.Collections.Generic; 21 | using System.Linq; 22 | using System.Text; 23 | using System.Threading.Tasks; 24 | using System.Net; 25 | using System.Threading; 26 | using System.IO; 27 | using OpenTidl.Models.Base; 28 | using System.Runtime.Serialization; 29 | 30 | namespace OpenTidl.Transport 31 | { 32 | internal class RestClient 33 | { 34 | #region properties 35 | 36 | internal String ApiEndpoint { get; private set; } 37 | internal String UserAgent { get; private set; } 38 | internal KeyValuePair[] Headers { get; private set; } 39 | 40 | #endregion 41 | 42 | 43 | #region methods 44 | 45 | internal async Task> Process(String path, Object query, Object request, String method, params KeyValuePair[] extraHeaders) where T : ModelBase 46 | { 47 | var encoding = new UTF8Encoding(false); 48 | var queryString = RestUtility.GetFormEncodedString(query); 49 | var url = String.IsNullOrEmpty(queryString) ? String.Format("{0}{1}", ApiEndpoint, path) : 50 | String.Format("{0}{1}?{2}", ApiEndpoint, path, queryString); 51 | var req = CreateRequest(url, method, extraHeaders); 52 | if (request != null) 53 | { 54 | req.ContentType = "application/x-www-form-urlencoded; charset=UTF-8"; 55 | using (var sw = new StreamWriter(req.GetRequestStream(), encoding)) 56 | sw.Write(RestUtility.GetFormEncodedString(request)); 57 | } 58 | HttpWebResponse response; 59 | try 60 | { 61 | response = (await req.GetResponseAsync()) as HttpWebResponse; 62 | } 63 | catch (WebException webEx) 64 | { 65 | response = webEx.Response as HttpWebResponse; 66 | } 67 | catch (Exception ex) 68 | { 69 | return new RestResponse(ex); 70 | } 71 | using (var sr = new StreamReader(response.GetResponseStream(), encoding)) 72 | { 73 | return new RestResponse(sr.ReadToEnd(), (Int32)response.StatusCode, response.Headers[HttpResponseHeader.ETag]); 74 | } 75 | } 76 | 77 | internal Stream GetStream(String url) 78 | { 79 | try 80 | { 81 | var response = GetWebResponse(url); 82 | if (response != null) 83 | return response.GetResponseStream(); 84 | } 85 | catch { } 86 | return null; 87 | } 88 | 89 | internal HttpWebResponse GetWebResponse(String url) 90 | { 91 | var req = CreateRequest(url, "GET", null); 92 | req.Timeout = 2000; 93 | try 94 | { 95 | return req.GetResponse() as HttpWebResponse; 96 | } 97 | catch 98 | { 99 | return null; 100 | } 101 | } 102 | 103 | private HttpWebRequest CreateRequest(String url, String method, KeyValuePair[] extraHeaders) 104 | { 105 | var req = HttpWebRequest.Create(url) as HttpWebRequest; 106 | req.UserAgent = this.UserAgent; 107 | req.Method = method; 108 | if (this.Headers != null) 109 | { 110 | foreach (var h in this.Headers) 111 | req.Headers[h.Key] = h.Value; 112 | } 113 | if (extraHeaders != null) 114 | { 115 | foreach (var h in extraHeaders) 116 | req.Headers[h.Key] = h.Value; 117 | } 118 | return req; 119 | } 120 | 121 | #endregion 122 | 123 | 124 | #region construction 125 | 126 | internal RestClient(String apiEndpoint, String userAgent, params KeyValuePair[] headers) 127 | { 128 | this.ApiEndpoint = apiEndpoint ?? ""; 129 | this.UserAgent = userAgent; 130 | this.Headers = headers; 131 | } 132 | 133 | #endregion 134 | } 135 | } 136 | -------------------------------------------------------------------------------- /OpenTidl/Transport/RestResponse.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2015 Jack Fagner 3 | 4 | This file is part of OpenTidl. 5 | 6 | OpenTidl is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU Affero General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | OpenTidl is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU Affero General Public License for more details. 15 | 16 | You should have received a copy of the GNU Affero General Public License 17 | along with OpenTidl. If not, see . 18 | */ 19 | using System; 20 | using System.Collections.Generic; 21 | using System.Linq; 22 | using System.Text; 23 | using System.Threading.Tasks; 24 | using OpenTidl.Models.Base; 25 | using System.Runtime.Serialization; 26 | using System.Runtime.Serialization.Json; 27 | using System.IO; 28 | 29 | namespace OpenTidl.Transport 30 | { 31 | public class RestResponse where T : ModelBase 32 | { 33 | #region properties 34 | 35 | public T Model { get; private set; } 36 | public Int32 StatusCode { get; private set; } 37 | public Exception Exception { get; internal set; } 38 | 39 | #endregion 40 | 41 | 42 | #region methods 43 | 44 | private TModel DeserializeObject(String data) where TModel : class 45 | { 46 | if (String.IsNullOrEmpty(data)) 47 | return Activator.CreateInstance(); 48 | var serializer = new DataContractJsonSerializer(typeof(TModel)); 49 | using (var ms = new MemoryStream(Encoding.UTF8.GetBytes(data))) 50 | { 51 | return serializer.ReadObject(ms) as TModel; 52 | } 53 | } 54 | 55 | #endregion 56 | 57 | 58 | #region construction 59 | 60 | public RestResponse(String responseData, Int32 statusCode, String eTag) 61 | { 62 | if (statusCode < 300) 63 | this.Model = DeserializeObject(responseData); 64 | if (statusCode >= 400) 65 | this.Exception = new OpenTidlException(DeserializeObject(responseData)); 66 | this.StatusCode = statusCode; 67 | if (this.Model != null) 68 | (this.Model as ModelBase).ETag = eTag; 69 | } 70 | 71 | public RestResponse(Exception ex) 72 | { 73 | this.Exception = ex; 74 | } 75 | 76 | #endregion 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /OpenTidl/Transport/RestUtility.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2015 Jack Fagner 3 | 4 | This file is part of OpenTidl. 5 | 6 | OpenTidl is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU Affero General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | OpenTidl is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU Affero General Public License for more details. 15 | 16 | You should have received a copy of the GNU Affero General Public License 17 | along with OpenTidl. If not, see . 18 | */ 19 | using System; 20 | using System.Collections.Generic; 21 | using System.Linq; 22 | using System.Text; 23 | using System.Threading.Tasks; 24 | using System.Net; 25 | using System.Text.RegularExpressions; 26 | 27 | namespace OpenTidl.Transport 28 | { 29 | internal static class RestUtility 30 | { 31 | internal static String GetFormEncodedString(Object data) 32 | { 33 | if (data == null) 34 | return null; 35 | return String.Join("&", data.GetType().GetProperties().Select(o => 36 | String.Format("{0}={1}", WebUtility.UrlEncode(o.Name), FormEncode(o.GetValue(data))))); 37 | } 38 | 39 | private static String FormEncode(Object value) 40 | { 41 | if (value == null) 42 | return String.Empty; 43 | return WebUtility.UrlEncode(value.ToString()); 44 | } 45 | 46 | internal static String FormatUrl(String format, Object data) 47 | { 48 | var dict = data == null ? new Dictionary() : 49 | data.GetType().GetProperties().ToDictionary(o => o.Name, o => FormEncode(o.GetValue(data))); 50 | return Regex.Replace(format, @"\{(\w+)\}", (m) => { 51 | return dict.ContainsKey(m.Groups[1].Value) ? dict[m.Groups[1].Value] : ""; 52 | }, RegexOptions.Singleline); 53 | } 54 | 55 | internal static T ParseEnum(String value) where T : struct 56 | { 57 | T result; 58 | if (Enum.TryParse(value, true, out result)) 59 | return result; 60 | return (T)Enum.ToObject(typeof(T), 0); 61 | //return Enum.GetValues(typeof(T)).OfType().FirstOrDefault(); 62 | } 63 | 64 | internal static String FormatDate(DateTime? date) 65 | { 66 | if (date.HasValue) 67 | return date.Value.ToString("yyyy-MM-ddTHH:mm:ss.fffzzz"); 68 | return ""; 69 | } 70 | 71 | internal static DateTime? ParseDate(String value) 72 | { 73 | if (String.IsNullOrEmpty(value)) 74 | return null; 75 | DateTime date; 76 | if (DateTime.TryParse(value, out date)) 77 | return date; 78 | return null; 79 | } 80 | 81 | internal static Boolean ParseImageSize(String sizeStr, out Int32 width, out Int32 height) 82 | { 83 | width = 0; 84 | height = 0; 85 | var match = Regex.Match(sizeStr ?? "", @"_(?\d+)x(?\d+)$", RegexOptions.Singleline); 86 | if (!match.Success) 87 | return false; 88 | width = Int32.Parse(match.Groups["w"].Value); 89 | height = Int32.Parse(match.Groups["h"].Value); 90 | return true; 91 | } 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # OpenTidl 2 | **Free and open source API for TIDAL music streaming service** 3 | 4 | This API is wirtten in C# 5.0 (.NET 4.5) and has no external dependencies. 5 | 6 | Most (relevant) functions used by TIDAL's web player or Android app are implemented, including: 7 | * Searching (albums, artists, tracks, videos) 8 | * Fetching metadata for albums, artists, tracks (including cover art, artist pictures, etc) 9 | * Logging in using username/password, Facebook, SPID, etc. Only username/password is fully tested. 10 | * Playlist management 11 | * Favorite album/artist/track/playlist management 12 | * Streaming tracks, including lossless, and videos - up to 1080p 13 | 14 | Searching and fetching metadata for albums/artists/tracks does not require an active TIDAL subscription. 15 | 16 | ## Installation 17 | OpenTidl is now available on [NuGet](https://www.nuget.org/packages/OpenTidl/) 18 | ``` 19 | PM> Install-Package OpenTidl 20 | ``` 21 | 22 | 23 | ## Disclaimer 24 | This product uses TIDAL but is not endorsed, certified or otherwise approved in any way by TIDAL. TIDAL is the registered trade mark of Aspiro. 25 | --------------------------------------------------------------------------------