├── Documentation ├── index.md ├── api │ ├── index.md │ └── .gitignore ├── articles │ ├── intro.md │ └── toc.yml ├── images │ └── favicon.ico ├── twixel_template │ └── favicon.ico ├── toc.yml ├── .gitignore ├── README.md └── docfx.json ├── Twixel ├── Custom Packages │ ├── Flurl.dll │ └── Flurl.XML ├── CheermoteTier.cs ├── CreateVideoResponse.cs ├── TwixelObjectBase.cs ├── Cheermote.cs ├── TwitchException.cs ├── Total.cs ├── Properties │ └── AssemblyInfo.cs ├── Badge.cs ├── SearchedGame.cs ├── EmoticonImage.cs ├── Block.cs ├── Subscription.cs ├── Follow.cs ├── TwixelException.cs ├── Twixel.csproj ├── Emoticon.cs ├── Ingest.cs ├── Community.cs ├── Game.cs ├── VideoObject.cs ├── FeaturedStream.cs ├── Stream.cs ├── Team.cs ├── Channel.cs ├── Video.cs ├── TwitchConstants.cs └── HelperMethods.cs ├── README.md ├── LICENSE ├── Twixel.Tests ├── Properties │ └── AssemblyInfo.cs ├── Twixel.Tests.csproj ├── Twixelv3Tests.cs ├── Twixelv5Tests.cs ├── Twixelv3UserTests.cs └── Twixelv5UserTests.cs ├── .gitattributes ├── .gitignore └── Twixel.sln /Documentation/index.md: -------------------------------------------------------------------------------- 1 | # Twixel 2 | -------------------------------------------------------------------------------- /Documentation/api/index.md: -------------------------------------------------------------------------------- 1 | # Twixel 2 | -------------------------------------------------------------------------------- /Documentation/articles/intro.md: -------------------------------------------------------------------------------- 1 | # Add your introductions here! 2 | -------------------------------------------------------------------------------- /Documentation/articles/toc.yml: -------------------------------------------------------------------------------- 1 | - name: Introduction 2 | href: intro.md 3 | -------------------------------------------------------------------------------- /Documentation/api/.gitignore: -------------------------------------------------------------------------------- 1 | ############### 2 | # temp file # 3 | ############### 4 | *.yml 5 | .manifest 6 | -------------------------------------------------------------------------------- /Documentation/images/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/golf1052/Twixel/HEAD/Documentation/images/favicon.ico -------------------------------------------------------------------------------- /Twixel/Custom Packages/Flurl.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/golf1052/Twixel/HEAD/Twixel/Custom Packages/Flurl.dll -------------------------------------------------------------------------------- /Documentation/twixel_template/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/golf1052/Twixel/HEAD/Documentation/twixel_template/favicon.ico -------------------------------------------------------------------------------- /Documentation/toc.yml: -------------------------------------------------------------------------------- 1 | - name: Articles 2 | href: articles/ 3 | - name: Api Documentation 4 | href: api/ 5 | homepage: api/index.md 6 | -------------------------------------------------------------------------------- /Documentation/.gitignore: -------------------------------------------------------------------------------- 1 | ############### 2 | # folder # 3 | ############### 4 | /**/DROP/ 5 | /**/TEMP/ 6 | /**/packages/ 7 | /**/bin/ 8 | /**/obj/ 9 | _site 10 | -------------------------------------------------------------------------------- /Documentation/README.md: -------------------------------------------------------------------------------- 1 | # Twixel Documentation 2 | 3 | This documentation is built using [docfx](http://dotnet.github.io/docfx/). 4 | 5 | ## How to Build and Deploy Said Documentation 6 | 7 | 1. `git checkout gh-pages` 8 | 2. `docfx build Documentation/docfx.json` 9 | 3. `cp -r Documentation/_site/* .` 10 | 4. `git commit -m "updated documentation"` 11 | 5. `git push` 12 | -------------------------------------------------------------------------------- /Twixel/CheermoteTier.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using Newtonsoft.Json.Linq; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Text; 6 | 7 | namespace TwixelAPI 8 | { 9 | public class CheermoteTier 10 | { 11 | [JsonProperty("min_bits")] 12 | public int MinBits { get; private set; } 13 | 14 | [JsonProperty("id")] 15 | public string Id { get; private set; } 16 | 17 | [JsonProperty("color")] 18 | public string Color { get; private set; } 19 | 20 | [JsonProperty("images")] 21 | public JObject Images { get; private set; } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Twixel/CreateVideoResponse.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using Newtonsoft.Json.Linq; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Text; 6 | using TwixelAPI.Constants; 7 | 8 | namespace TwixelAPI 9 | { 10 | internal class CreateVideoResponse 11 | { 12 | [JsonProperty("upload")] 13 | public UploadObject Upload { get; private set; } 14 | 15 | [JsonProperty("video")] 16 | public VideoObject Video { get; private set; } 17 | 18 | internal class UploadObject 19 | { 20 | [JsonProperty("token")] 21 | public string Token { get; private set; } 22 | 23 | [JsonProperty("url")] 24 | public string Url { get; private set; } 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Twixel 2 | 3 | Unofficial C# Twitch.TV API Wrapper 4 | Supports Twitch API v3 and most of v5 5 | Supports .NET Core/.NET Standard 6 | Official documentation can be found [here](https://dev.twitch.tv/docs) 7 | 8 | [NuGet package supporting v2 and v3](https://www.nuget.org/packages/Twixel/2.0.4) 9 | [Beta release of v5 support](https://preview.nuget.org/packages/Twixel/3.0.0-beta) 10 | 11 | ## Current Status 12 | 13 | Twitch announced the next version of their API on August 31, 2017. See [link](https://blog.twitch.tv/the-new-twitch-api-be3fb2b078e6) v5 was deprecated and both v3 and v5 will be removed on December 31, 2018. Because of this the next updates to this library will be updates supporting the next version of Twitch's API. 14 | 15 | [Whenever that happens.](https://dev.twitch.tv/roadmap) 16 | -------------------------------------------------------------------------------- /Twixel/TwixelObjectBase.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Newtonsoft.Json.Linq; 4 | 5 | namespace TwixelAPI 6 | { 7 | /// 8 | /// TwixelObjectBase object. 9 | /// All Twixel objects (except for Emoticons) derive from this. 10 | /// 11 | public class TwixelObjectBase 12 | { 13 | /// 14 | /// Twitch API version that was used to create this object 15 | /// 16 | public Twixel.APIVersion version; 17 | 18 | /// 19 | /// Base links 20 | /// 21 | public Dictionary baseLinks; 22 | 23 | /// 24 | /// TwixelObjectBase constructor 25 | /// 26 | /// Base links JSON object 27 | public TwixelObjectBase(JObject baseLinksO) 28 | { 29 | baseLinks = HelperMethods.LoadLinks(baseLinksO); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Twixel/Cheermote.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | namespace TwixelAPI 7 | { 8 | public class Cheermote 9 | { 10 | [JsonProperty("prefix")] 11 | public string Prefix { get; private set; } 12 | 13 | [JsonProperty("scales")] 14 | public List Scales { get; private set; } 15 | 16 | [JsonProperty("tiers")] 17 | public List Tiers { get; private set; } 18 | 19 | [JsonProperty("backgrounds")] 20 | public List Backgrounds { get; private set; } 21 | 22 | [JsonProperty("states")] 23 | public List States { get; private set; } 24 | 25 | [JsonProperty("type")] 26 | public string Type { get; private set; } 27 | 28 | [JsonProperty("updated_at")] 29 | public DateTimeOffset UpdatedAt { get; private set; } 30 | 31 | [JsonProperty("priority")] 32 | public int Priority { get; private set; } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Twixel/TwitchException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Newtonsoft.Json.Linq; 3 | 4 | namespace TwixelAPI 5 | { 6 | /// 7 | /// Twitch exception 8 | /// 9 | public class TwitchException : Exception 10 | { 11 | /// 12 | /// Twitch error 13 | /// 14 | public string Error { get; private set; } 15 | 16 | /// 17 | /// HTTP error code 18 | /// 19 | public int Status { get; private set; } 20 | 21 | /// 22 | /// TwitchException constructor 23 | /// 24 | /// Error JSON object 25 | public TwitchException(JObject errorO) : base((string)errorO["message"]) 26 | { 27 | Error = (string)errorO["error"]; 28 | Status = (int)errorO["status"]; 29 | } 30 | 31 | public TwitchException(string message, string error, int status) : base(message) 32 | { 33 | Error = error; 34 | Status = status; 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Sanders Lauture 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Twixel/Total.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json.Linq; 2 | 3 | namespace TwixelAPI 4 | { 5 | /// 6 | /// Total object 7 | /// 8 | /// Wrapped object 9 | public class Total : TwixelObjectBase 10 | { 11 | /// 12 | /// Total number of objects, not just in wrapped 13 | /// 14 | public long? total; 15 | 16 | /// 17 | /// Wrapped object 18 | /// 19 | public T wrapped; 20 | 21 | /// 22 | /// Total constructor 23 | /// 24 | /// Total number of objects 25 | /// Wrapped object 26 | /// Twitch API version 27 | /// Base links JSON object 28 | public Total(long? total, T t, 29 | Twixel.APIVersion version, JObject baseLinksO) : base(baseLinksO) 30 | { 31 | this.version = version; 32 | this.total = total; 33 | this.wrapped = t; 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Twixel/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Resources; 2 | using System.Reflection; 3 | using System.Runtime.CompilerServices; 4 | using System.Runtime.InteropServices; 5 | 6 | // General Information about an assembly is controlled through the following 7 | // set of attributes. Change these attribute values to modify the information 8 | // associated with an assembly. 9 | [assembly: AssemblyTitle("Twixel")] 10 | [assembly: AssemblyDescription("")] 11 | [assembly: AssemblyConfiguration("")] 12 | [assembly: AssemblyCompany("")] 13 | [assembly: AssemblyProduct("Twixel")] 14 | [assembly: AssemblyCopyright("Copyright © 2013")] 15 | [assembly: AssemblyTrademark("")] 16 | [assembly: AssemblyCulture("")] 17 | [assembly: NeutralResourcesLanguage("en")] 18 | 19 | // Version information for an assembly consists of the following four values: 20 | // 21 | // Major Version 22 | // Minor Version 23 | // Build Number 24 | // Revision 25 | // 26 | // You can specify all the values or you can default the Build and Revision Numbers 27 | // by using the '*' as shown below: 28 | // [assembly: AssemblyVersion("1.0.*")] 29 | [assembly: AssemblyVersion("1.0.0.0")] 30 | [assembly: AssemblyFileVersion("1.0.0.0")] 31 | -------------------------------------------------------------------------------- /Twixel.Tests/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Resources; 2 | using System.Reflection; 3 | using System.Runtime.CompilerServices; 4 | using System.Runtime.InteropServices; 5 | 6 | // General Information about an assembly is controlled through the following 7 | // set of attributes. Change these attribute values to modify the information 8 | // associated with an assembly. 9 | [assembly: AssemblyTitle("Twixel.Tests")] 10 | [assembly: AssemblyDescription("")] 11 | [assembly: AssemblyConfiguration("")] 12 | [assembly: AssemblyCompany("")] 13 | [assembly: AssemblyProduct("Twixel.Tests")] 14 | [assembly: AssemblyCopyright("Copyright © 2014")] 15 | [assembly: AssemblyTrademark("")] 16 | [assembly: AssemblyCulture("")] 17 | [assembly: NeutralResourcesLanguage("en")] 18 | 19 | // Version information for an assembly consists of the following four values: 20 | // 21 | // Major Version 22 | // Minor Version 23 | // Build Number 24 | // Revision 25 | // 26 | // You can specify all the values or you can default the Build and Revision Numbers 27 | // by using the '*' as shown below: 28 | // [assembly: AssemblyVersion("1.0.*")] 29 | [assembly: AssemblyVersion("1.0.0.0")] 30 | [assembly: AssemblyFileVersion("1.0.0.0")] 31 | -------------------------------------------------------------------------------- /Twixel/Badge.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Newtonsoft.Json.Linq; 4 | 5 | namespace TwixelAPI 6 | { 7 | /// 8 | /// Badge object 9 | /// 10 | public class Badge : TwixelObjectBase 11 | { 12 | /// 13 | /// Badge name 14 | /// 15 | public string name; 16 | 17 | /// 18 | /// Badge image links 19 | /// 20 | public Dictionary links; 21 | 22 | /// 23 | /// Badge constructor 24 | /// 25 | /// Badge name 26 | /// Badge image links 27 | /// Twitch API version 28 | /// Base links JSON object 29 | public Badge(string name, 30 | JObject linksO, 31 | Twixel.APIVersion version, 32 | JObject baseLinksO) : base(baseLinksO) 33 | { 34 | this.version = version; 35 | this.name = name; 36 | if (linksO != null) 37 | { 38 | this.links = HelperMethods.LoadLinks(linksO); 39 | } 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Twixel/SearchedGame.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json.Linq; 2 | 3 | namespace TwixelAPI 4 | { 5 | /// 6 | /// SearchedGame object 7 | /// 8 | public class SearchedGame : Game 9 | { 10 | /// 11 | /// Popularity 12 | /// 13 | public long? popularity; 14 | 15 | /// 16 | /// SearchedGame constructor 17 | /// 18 | /// Name 19 | /// Popularity 20 | /// ID 21 | /// GiantBomb ID 22 | /// Box JSON object 23 | /// Logo JSON object 24 | /// Twitch API version 25 | /// Base links JSON object 26 | public SearchedGame(string name, 27 | long? popularity, 28 | long? id, 29 | long? giantBombId, 30 | JObject boxO, 31 | JObject logoO, 32 | Twixel.APIVersion version, 33 | JObject baseLinksO) : base(null, null, name, id, giantBombId, boxO, logoO, version, baseLinksO) 34 | { 35 | this.popularity = popularity; 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Twixel/EmoticonImage.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace TwixelAPI 4 | { 5 | /// 6 | /// EmoticonImage object 7 | /// 8 | public class EmoticonImage 9 | { 10 | /// 11 | /// Emoticon set. 12 | /// If null emoticon is part of the default Twitch set. 13 | /// 14 | public int? emoticonSet; 15 | 16 | /// 17 | /// Height in pixels 18 | /// 19 | public int height; 20 | 21 | /// 22 | /// Width in pixels 23 | /// 24 | public int width; 25 | 26 | /// 27 | /// Link to image 28 | /// 29 | public Uri url; 30 | 31 | /// 32 | /// EmoticonImage constructor 33 | /// 34 | /// Emoticon set 35 | /// Height in pixels 36 | /// Width in pixels 37 | /// Link to image 38 | public EmoticonImage(int? emoticonSet, int height, int width, string url) 39 | { 40 | this.emoticonSet = emoticonSet; 41 | this.height = height; 42 | this.width = width; 43 | this.url = new Uri(url); 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /Twixel/Block.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Newtonsoft.Json.Linq; 3 | 4 | namespace TwixelAPI 5 | { 6 | /// 7 | /// Block object 8 | /// 9 | public class Block : TwixelObjectBase 10 | { 11 | /// 12 | /// Last updated 13 | /// 14 | public DateTime updatedAt; 15 | 16 | /// 17 | /// Block ID 18 | /// 19 | public long id; 20 | 21 | /// 22 | /// User that is blocked 23 | /// 24 | public User user; 25 | 26 | /// 27 | /// Block constructor 28 | /// 29 | /// Last updated at as a string 30 | /// Block ID 31 | /// User JSON object 32 | /// Twitch API version 33 | /// Base links JSON object 34 | public Block(string updatedAt, 35 | long id, 36 | JObject userO, 37 | Twixel.APIVersion version, 38 | JObject baseLinksO) : base(baseLinksO) 39 | { 40 | this.version = version; 41 | this.updatedAt = DateTime.Parse(updatedAt); 42 | this.id = id; 43 | this.user = HelperMethods.LoadUser(userO, version); 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /Twixel/Subscription.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Newtonsoft.Json.Linq; 3 | 4 | namespace TwixelAPI 5 | { 6 | /// 7 | /// Subscription object 8 | /// 9 | /// Wrapped object, usually either User or Channel object 10 | public class Subscription : TwixelObjectBase 11 | { 12 | /// 13 | /// ID 14 | /// 15 | public string id; 16 | 17 | /// 18 | /// Creation date 19 | /// 20 | public DateTime createdAt; 21 | 22 | /// 23 | /// Wrapped object, usually either User or Channel object 24 | /// 25 | public T wrapped; 26 | 27 | /// 28 | /// Subscription constructor 29 | /// 30 | /// Creation date 31 | /// ID 32 | /// Wrapped object 33 | /// Twitch API version 34 | /// Base links JSON object 35 | public Subscription(string createdAt, 36 | string id, 37 | T t, 38 | Twixel.APIVersion version, 39 | JObject baseLinksO) : base(baseLinksO) 40 | { 41 | this.version = version; 42 | this.createdAt = DateTime.Parse(createdAt); 43 | this.id = id; 44 | this.wrapped = t; 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /Twixel/Follow.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Newtonsoft.Json.Linq; 3 | 4 | namespace TwixelAPI 5 | { 6 | /// 7 | /// Follow object 8 | /// 9 | /// Wrapped object, usually either User or Channel object 10 | public class Follow : TwixelObjectBase 11 | { 12 | /// 13 | /// Creation date 14 | /// 15 | public DateTime createdAt; 16 | 17 | /// 18 | /// Notification status 19 | /// 20 | public bool notifications; 21 | 22 | /// 23 | /// Wrapped object, usually either User or Channel object 24 | /// 25 | public T wrapped; 26 | 27 | /// 28 | /// Follow constructor 29 | /// 30 | /// Creation date 31 | /// Notification status 32 | /// Wrapped object 33 | /// Twitch API version 34 | /// Base links JSON object 35 | public Follow(string createdAt, 36 | bool notifications, 37 | T t, 38 | Twixel.APIVersion version, 39 | JObject baseLinksO) : base(baseLinksO) 40 | { 41 | this.version = version; 42 | this.createdAt = DateTime.Parse(createdAt); 43 | this.notifications = notifications; 44 | this.wrapped = t; 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /Twixel/TwixelException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Newtonsoft.Json.Linq; 3 | 4 | namespace TwixelAPI 5 | { 6 | /// 7 | /// Twixel exception 8 | /// 9 | public class TwixelException : Exception 10 | { 11 | /// 12 | /// Base links 13 | /// 14 | public TwixelObjectBase BaseLinks { get; private set; } 15 | 16 | /// 17 | /// Wrapped Twitch exception 18 | /// 19 | public TwitchException Error { get; private set; } 20 | 21 | /// 22 | /// TwixelException constructor. Simple messages. 23 | /// 24 | /// Message 25 | public TwixelException(string message) : base(message) 26 | { 27 | } 28 | 29 | /// 30 | /// TwixelException constructor. Message with base links. 31 | /// 32 | /// Message 33 | /// Base links JSON object 34 | public TwixelException(string message, JObject baseLinksO) : base(message) 35 | { 36 | this.BaseLinks = new TwixelObjectBase(baseLinksO); 37 | } 38 | 39 | /// 40 | /// TwixelException constructor. Message with wrapped Twitch exception. 41 | /// 42 | /// Message 43 | /// Twitch exception 44 | public TwixelException(string message, TwitchException error) : base(message, error) 45 | { 46 | this.Error = error; 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /Documentation/docfx.json: -------------------------------------------------------------------------------- 1 | { 2 | "metadata": [ 3 | { 4 | "src": [ 5 | { 6 | "files": [ 7 | "Twixel/**.csproj" 8 | ], 9 | "exclude": [ 10 | "**/obj/**", 11 | "**/bin/**", 12 | "_site/**" 13 | ], 14 | "src": ".." 15 | } 16 | ], 17 | "dest": "api" 18 | } 19 | ], 20 | "build": { 21 | "content": [ 22 | { 23 | "files": [ 24 | "api/**.yml", 25 | "api/index.md" 26 | ] 27 | }, 28 | { 29 | "files": [ 30 | "articles/**.md", 31 | "articles/**/toc.yml", 32 | "toc.yml", 33 | "*.md" 34 | ], 35 | "exclude": [ 36 | "obj/**", 37 | "_site/**" 38 | ] 39 | } 40 | ], 41 | "resource": [ 42 | { 43 | "files": [ 44 | "images/**" 45 | ], 46 | "exclude": [ 47 | "obj/**", 48 | "_site/**" 49 | ] 50 | } 51 | ], 52 | "overwrite": [ 53 | { 54 | "files": [ 55 | "apidoc/**.md" 56 | ], 57 | "exclude": [ 58 | "obj/**", 59 | "_site/**" 60 | ] 61 | } 62 | ], 63 | "dest": "_site", 64 | "globalMetadata": { 65 | "_appFaviconPath": "favicon.ico", 66 | "_gitContribute": { 67 | "repo": "https://github.com/golf1052/Twixel", 68 | "branch": "master" 69 | } 70 | }, 71 | "globalMetadataFiles": [], 72 | "fileMetadataFiles": [], 73 | "template": [ 74 | "default", 75 | "twixel_template" 76 | ], 77 | "postProcessors": [], 78 | "noLangKeyword": false, 79 | "keepFileLink": false, 80 | "cleanupCacheHistory": false 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /Twixel/Twixel.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netstandard1.3 5 | Twixel 6 | Twixel 7 | 1.6.0 8 | false 9 | false 10 | false 11 | false 12 | false 13 | false 14 | false 15 | false 16 | false 17 | 18 | 19 | 20 | bin\Debug\netstandard1.3\Twixel.xml 21 | 22 | 23 | 24 | bin\Release\netstandard1.3\Twixel.xml 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /Twixel.Tests/Twixel.Tests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp1.1 5 | Twixel.Tests 6 | Twixel.Tests 7 | 1.6.0 8 | false 9 | false 10 | false 11 | false 12 | false 13 | false 14 | false 15 | false 16 | false 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /Twixel/Emoticon.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json.Linq; 3 | 4 | namespace TwixelAPI 5 | { 6 | /// 7 | /// Emoticon object 8 | /// 9 | public class Emoticon : TwixelObjectBase 10 | { 11 | /// 12 | /// Regex 13 | /// 14 | public string regex; 15 | 16 | /// 17 | /// List of emoticon images 18 | /// 19 | public List emoticonImages; 20 | 21 | /// 22 | /// Emoticon constructor 23 | /// 24 | /// Regex 25 | /// Emoticon images JSON object 26 | /// Twitch API version 27 | /// Base links JSON object 28 | public Emoticon(string regex, JArray imagesA, Twixel.APIVersion version, 29 | JObject baseLinksO) : base(baseLinksO) 30 | { 31 | this.version = version; 32 | emoticonImages = new List(); 33 | this.regex = regex; 34 | emoticonImages = LoadEmoticonImages(imagesA); 35 | } 36 | 37 | private List LoadEmoticonImages(JArray a) 38 | { 39 | List images = new List(); 40 | foreach(JObject o in a) 41 | { 42 | if (!string.IsNullOrEmpty((string)o["height"]) && 43 | !string.IsNullOrEmpty((string)o["width"]) && 44 | !string.IsNullOrEmpty((string)o["url"])) 45 | { 46 | images.Add(new EmoticonImage((int?)o["emoticon_set"], 47 | (int)o["height"], 48 | (int)o["width"], 49 | (string)o["url"])); 50 | } 51 | 52 | } 53 | return images; 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /Twixel/Ingest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Newtonsoft.Json.Linq; 3 | 4 | namespace TwixelAPI 5 | { 6 | /// 7 | /// Ingets object 8 | /// 9 | public class Ingest : TwixelObjectBase 10 | { 11 | /// 12 | /// Name 13 | /// 14 | public string name; 15 | 16 | /// 17 | /// Default status 18 | /// 19 | public bool defaultIngest; 20 | 21 | /// 22 | /// ID 23 | /// 24 | public long id; 25 | 26 | /// 27 | /// Url template. 28 | /// By directing an RTMP stream with a stream key injected into {stream_key}, you will broadcast content live on Twitch. 29 | /// 30 | public Uri urlTemplate; 31 | 32 | /// 33 | /// Availability 34 | /// 35 | public double avalibility; 36 | 37 | /// 38 | /// Ingest constructor 39 | /// 40 | /// Name 41 | /// Default status 42 | /// ID 43 | /// Url template 44 | /// Availability 45 | /// Twitch API version 46 | /// Base links JSON object 47 | public Ingest(string name, 48 | bool defaultIngest, 49 | long id, 50 | string urlTemplate, 51 | double avalibility, 52 | Twixel.APIVersion version, 53 | JObject baseLinksO) : base(baseLinksO) 54 | { 55 | this.version = version; 56 | this.name = name; 57 | this.defaultIngest = defaultIngest; 58 | this.id = id; 59 | this.urlTemplate = new Uri(urlTemplate); 60 | this.avalibility = avalibility; 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /Twixel/Community.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Newtonsoft.Json.Linq; 3 | 4 | namespace TwixelAPI 5 | { 6 | public class Community : TwixelObjectBase 7 | { 8 | public string id; 9 | public Uri avatarImageUrl; 10 | public Uri coverImageUrl; 11 | public string description; 12 | public string descriptionHtml; 13 | public string language; 14 | public string name; 15 | public long ownerId; 16 | public string rules; 17 | public string rulesHtml; 18 | public string summary; 19 | 20 | public Community(string id, 21 | string avatarImageUrl, 22 | string coverImageUrl, 23 | string description, 24 | string descriptionHtml, 25 | string language, 26 | string name, 27 | long ownerId, 28 | string rules, 29 | string rulesHtml, 30 | string summary, 31 | JObject baseLinksO) : base(baseLinksO) 32 | { 33 | this.id = id; 34 | if (!string.IsNullOrEmpty(avatarImageUrl)) 35 | { 36 | this.avatarImageUrl = new Uri(avatarImageUrl); 37 | } 38 | if (!string.IsNullOrEmpty(coverImageUrl)) 39 | { 40 | this.coverImageUrl = new Uri(coverImageUrl); 41 | } 42 | this.description = description; 43 | this.descriptionHtml = descriptionHtml; 44 | this.language = language; 45 | this.name = name; 46 | this.ownerId = ownerId; 47 | this.rules = rules; 48 | this.rulesHtml = rulesHtml; 49 | this.summary = summary; 50 | } 51 | 52 | public static Community LoadCommunity(JObject o, Twixel.APIVersion version) 53 | { 54 | return new Community((string)o["_id"], 55 | (string)o["avatar_image_url"], 56 | (string)o["cover_image_url"], 57 | (string)o["description"], 58 | (string)o["description_html"], 59 | (string)o["language"], 60 | (string)o["name"], 61 | (long)o["owner_id"], 62 | (string)o["rules"], 63 | (string)o["rules_html"], 64 | (string)o["summary"], 65 | null); 66 | } 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /Twixel/Game.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Newtonsoft.Json.Linq; 4 | 5 | namespace TwixelAPI 6 | { 7 | /// 8 | /// Game object 9 | /// 10 | public class Game : TwixelObjectBase 11 | { 12 | /// 13 | /// Number of viewers. 14 | /// Null if game was searched. 15 | /// 16 | public long? viewers; 17 | 18 | /// 19 | /// Number of channels. 20 | /// Null if game was searched 21 | /// 22 | public long? channels; 23 | 24 | /// 25 | /// Name 26 | /// 27 | public string name; 28 | 29 | /// 30 | /// ID 31 | /// 32 | public long? id; 33 | 34 | /// 35 | /// GiantBomb ID 36 | /// 37 | public long? giantBombId; 38 | 39 | /// 40 | /// Box image links. 41 | /// Dictionary strings: small, medium, large, template 42 | /// 43 | public Dictionary box; 44 | 45 | /// 46 | /// Logo image links. 47 | /// Dictionary strings: small, medium, large, template 48 | /// 49 | public Dictionary logo; 50 | 51 | /// 52 | /// Game constructor 53 | /// 54 | /// Number of viewers 55 | /// Number of channels 56 | /// Name 57 | /// ID 58 | /// GiantBomb ID 59 | /// Box JSON object 60 | /// Logo JSON object 61 | /// Twitch API version 62 | /// Base links JSON object 63 | public Game(long? viewers, 64 | long? channels, 65 | string name, 66 | long? id, 67 | long? giantBombId, 68 | JObject boxO, 69 | JObject logoO, 70 | Twixel.APIVersion version, 71 | JObject baseLinksO) : base (baseLinksO) 72 | { 73 | this.version = version; 74 | this.viewers = viewers; 75 | this.channels = channels; 76 | this.name = name; 77 | this.id = id; 78 | this.giantBombId = giantBombId; 79 | this.box = HelperMethods.LoadLinks(boxO); 80 | this.logo = HelperMethods.LoadLinks(logoO); 81 | } 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /.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 | -------------------------------------------------------------------------------- /Twixel/VideoObject.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using Newtonsoft.Json.Linq; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Text; 6 | 7 | namespace TwixelAPI 8 | { 9 | public class VideoObject 10 | { 11 | [JsonProperty("title")] 12 | public string Title { get; private set; } 13 | 14 | [JsonProperty("description")] 15 | public string Description { get; private set; } 16 | 17 | [JsonProperty("description_html")] 18 | public string DescriptionHtml { get; private set; } 19 | 20 | [JsonProperty("broadcast_id")] 21 | public long BroadcastId { get; private set; } 22 | 23 | [JsonProperty("broadcast_type")] 24 | public string BroadcastType { get; private set; } 25 | 26 | [JsonProperty("status")] 27 | public string Status { get; private set; } 28 | 29 | [JsonProperty("tag_list")] 30 | public string TagList { get; private set; } 31 | 32 | [JsonProperty("views")] 33 | public long Views { get; private set; } 34 | 35 | [JsonProperty("url")] 36 | public Uri url { get; private set; } 37 | 38 | [JsonProperty("language")] 39 | public string Language { get; private set; } 40 | 41 | [JsonProperty("created_at")] 42 | public DateTimeOffset CreatedAt { get; private set; } 43 | 44 | [JsonProperty("viewable")] 45 | public string Viewable { get; private set; } 46 | 47 | [JsonProperty("viewable_at")] 48 | public DateTimeOffset? ViewableAt { get; private set; } 49 | 50 | [JsonProperty("published_at")] 51 | public DateTimeOffset? PublishedAt { get; private set; } 52 | 53 | [JsonProperty("_id")] 54 | public string Id { get; private set; } 55 | 56 | [JsonProperty("recorded_at")] 57 | public DateTimeOffset RecordedAt { get; private set; } 58 | 59 | [JsonProperty("game")] 60 | public string Game { get; private set; } 61 | 62 | [JsonProperty("length")] 63 | public long Length { get; private set; } 64 | 65 | [JsonProperty("preview")] 66 | public Dictionary Preview { get; private set; } 67 | 68 | [JsonProperty("animated_preview_url")] 69 | public Uri AnimatedPreviewUrl { get; private set; } 70 | 71 | [JsonProperty("thumbnails")] 72 | public JObject Thumbnails { get; private set; } 73 | 74 | [JsonProperty("fps")] 75 | public Dictionary Fps { get; private set; } 76 | 77 | [JsonProperty("resolutions")] 78 | public JObject Resolutions { get; private set; } 79 | 80 | [JsonProperty("channel")] 81 | public JObject Channel { get; private set; } 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /Twixel/FeaturedStream.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Newtonsoft.Json.Linq; 3 | 4 | namespace TwixelAPI 5 | { 6 | /// 7 | /// FeaturedStream object 8 | /// 9 | public class FeaturedStream : TwixelObjectBase 10 | { 11 | /// 12 | /// Description text. 13 | /// Contains HTML tags by default. 14 | /// v2/v3 15 | /// 16 | public string text; 17 | 18 | /// 19 | /// Link to image 20 | /// v2/v3 21 | /// 22 | public Uri image; 23 | 24 | /// 25 | /// Title 26 | /// v3 27 | /// 28 | public string title; 29 | 30 | /// 31 | /// Sponsored status 32 | /// v3 33 | /// 34 | public bool sponsored; 35 | 36 | /// 37 | /// Priority 38 | /// v3 39 | /// 40 | public int priority; 41 | 42 | /// 43 | /// Scheduled status 44 | /// v3 45 | /// 46 | public bool scheduled; 47 | 48 | /// 49 | /// Stream object 50 | /// v2/v3 51 | /// 52 | public Stream stream; 53 | 54 | /// 55 | /// FeaturedStream constructor, Twitch API v3 56 | /// 57 | /// Description text 58 | /// Link to image 59 | /// Title 60 | /// Sponsored status 61 | /// Priority 62 | /// Scheduled status 63 | /// Stream JSON object 64 | /// Base links JSON object 65 | public FeaturedStream(string text, 66 | string image, 67 | string title, 68 | bool sponsored, 69 | int priority, 70 | bool scheduled, 71 | JObject streamO, 72 | JObject baseLinksO) : base(baseLinksO) 73 | { 74 | this.version = Twixel.APIVersion.v3; 75 | this.text = text; 76 | if (!string.IsNullOrEmpty(image)) 77 | { 78 | this.image = new Uri(image); 79 | } 80 | this.title = title; 81 | this.sponsored = sponsored; 82 | this.priority = priority; 83 | this.scheduled = scheduled; 84 | this.stream = HelperMethods.LoadStream(streamO, version); 85 | } 86 | 87 | /// 88 | /// Remove HTML tags and HTML decode info string 89 | /// 90 | public void CleanTextString() 91 | { 92 | text = HelperMethods.ConvertAmp(HelperMethods.RemoveHtmlTags(text)).Trim(); 93 | char lastChar = '\0'; 94 | for (int i = 0; i < text.Length; i++) 95 | { 96 | if (text[i] == '\n') 97 | { 98 | if (lastChar == '\n') 99 | { 100 | i -= 1; 101 | text = text.Remove(i); 102 | break; 103 | } 104 | } 105 | lastChar = text[i]; 106 | } 107 | } 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | Twixel.Tests/Secrets.cs 2 | .vs/ 3 | 4 | ## Ignore Visual Studio temporary files, build results, and 5 | ## files generated by popular Visual Studio add-ons. 6 | 7 | # User-specific files 8 | *.suo 9 | *.user 10 | *.sln.docstates 11 | 12 | # Build results 13 | [Dd]ebug/ 14 | [Dd]ebugPublic/ 15 | [Rr]elease/ 16 | [Rr]eleases/ 17 | x64/ 18 | x86/ 19 | build/ 20 | bld/ 21 | [Bb]in/ 22 | [Oo]bj/ 23 | 24 | # Roslyn cache directories 25 | *.ide/ 26 | 27 | # MSTest test Results 28 | [Tt]est[Rr]esult*/ 29 | [Bb]uild[Ll]og.* 30 | 31 | #NUNIT 32 | *.VisualState.xml 33 | TestResult.xml 34 | 35 | # Build Results of an ATL Project 36 | [Dd]ebugPS/ 37 | [Rr]eleasePS/ 38 | dlldata.c 39 | 40 | *_i.c 41 | *_p.c 42 | *_i.h 43 | *.ilk 44 | *.meta 45 | *.obj 46 | *.pch 47 | *.pdb 48 | *.pgc 49 | *.pgd 50 | *.rsp 51 | *.sbr 52 | *.tlb 53 | *.tli 54 | *.tlh 55 | *.tmp 56 | *.tmp_proj 57 | *.log 58 | *.vspscc 59 | *.vssscc 60 | .builds 61 | *.pidb 62 | *.svclog 63 | *.scc 64 | 65 | # Chutzpah Test files 66 | _Chutzpah* 67 | 68 | # Visual C++ cache files 69 | ipch/ 70 | *.aps 71 | *.ncb 72 | *.opensdf 73 | *.sdf 74 | *.cachefile 75 | 76 | # Visual Studio profiler 77 | *.psess 78 | *.vsp 79 | *.vspx 80 | 81 | # TFS 2012 Local Workspace 82 | $tf/ 83 | 84 | # Guidance Automation Toolkit 85 | *.gpState 86 | 87 | # ReSharper is a .NET coding add-in 88 | _ReSharper*/ 89 | *.[Rr]e[Ss]harper 90 | *.DotSettings.user 91 | 92 | # JustCode is a .NET coding addin-in 93 | .JustCode 94 | 95 | # TeamCity is a build add-in 96 | _TeamCity* 97 | 98 | # DotCover is a Code Coverage Tool 99 | *.dotCover 100 | 101 | # NCrunch 102 | _NCrunch_* 103 | .*crunch*.local.xml 104 | 105 | # MightyMoose 106 | *.mm.* 107 | AutoTest.Net/ 108 | 109 | # Web workbench (sass) 110 | .sass-cache/ 111 | 112 | # Installshield output folder 113 | [Ee]xpress/ 114 | 115 | # DocProject is a documentation generator add-in 116 | DocProject/buildhelp/ 117 | DocProject/Help/*.HxT 118 | DocProject/Help/*.HxC 119 | DocProject/Help/*.hhc 120 | DocProject/Help/*.hhk 121 | DocProject/Help/*.hhp 122 | DocProject/Help/Html2 123 | DocProject/Help/html 124 | 125 | # Click-Once directory 126 | publish/ 127 | 128 | # Publish Web Output 129 | *.[Pp]ublish.xml 130 | *.azurePubxml 131 | # TODO: Comment the next line if you want to checkin your web deploy settings 132 | # but database connection strings (with potential passwords) will be unencrypted 133 | *.pubxml 134 | 135 | # NuGet Packages 136 | *.nupkg 137 | # The packages folder can be ignored because of Package Restore 138 | **/packages/* 139 | # except build/, which is used as an MSBuild target. 140 | !**/packages/build/ 141 | # If using the old MSBuild-Integrated Package Restore, uncomment this: 142 | #!**/packages/repositories.config 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 | -------------------------------------------------------------------------------- /Twixel/Stream.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Newtonsoft.Json.Linq; 4 | 5 | namespace TwixelAPI 6 | { 7 | /// 8 | /// Stream object 9 | /// 10 | public class Stream : TwixelObjectBase 11 | { 12 | /// 13 | /// ID 14 | /// v2/v3 15 | /// 16 | public long? id; 17 | 18 | /// 19 | /// Current game, can be null 20 | /// v2/v3 21 | /// 22 | public string game; 23 | 24 | /// 25 | /// Number of viewers 26 | /// v2/v3 27 | /// 28 | public long? viewers; 29 | 30 | /// 31 | /// Creation date 32 | /// v2/v3 33 | /// 34 | public DateTime createdAt; 35 | 36 | /// 37 | /// Video height 38 | /// v2/v3 39 | /// 40 | public int? videoHeight; 41 | 42 | /// 43 | /// Average FPS 44 | /// v2/v3 45 | /// 46 | public double? averageFps; 47 | 48 | /// 49 | /// Name 50 | /// v2/v3 51 | /// 52 | public string name; 53 | 54 | /// 55 | /// Broadcaster software used 56 | /// v2/v3 57 | /// 58 | public string broadcaster; 59 | 60 | /// 61 | /// Link to preview image 62 | /// v2 63 | /// 64 | public Uri preview; 65 | 66 | /// 67 | /// Link to preview images 68 | /// Dictionary strings: small, medium, large, template 69 | /// v3 70 | /// 71 | public Dictionary previewList; 72 | 73 | /// 74 | /// Channel object 75 | /// v2/v3 76 | /// 77 | public Channel channel; 78 | 79 | /// 80 | /// Stream constructor, Twitch API v3 81 | /// 82 | /// ID 83 | /// Current game, can be null 84 | /// Number of viewers 85 | /// Creation date 86 | /// Video height 87 | /// Average FPS 88 | /// Name 89 | /// Broadcaster softare used 90 | /// Preview JSON object 91 | /// Channel JSON object 92 | /// Base links JSON object 93 | public Stream(long? id, 94 | string game, 95 | long? viewers, 96 | string createdAt, 97 | int videoHeight, 98 | double averageFps, 99 | string name, 100 | string broadcaster, 101 | JObject previewO, 102 | JObject channelO, 103 | JObject baseLinksO) 104 | : base(baseLinksO) 105 | { 106 | this.version = Twixel.APIVersion.v3; 107 | this.id = id; 108 | this.game = game; 109 | this.viewers = viewers; 110 | this.createdAt = DateTime.Parse(createdAt); 111 | this.videoHeight = videoHeight; 112 | this.averageFps = averageFps; 113 | this.name = name; 114 | this.broadcaster = broadcaster; 115 | this.previewList = HelperMethods.LoadLinks(previewO); 116 | this.channel = HelperMethods.LoadChannel(channelO, version); 117 | } 118 | } 119 | } 120 | -------------------------------------------------------------------------------- /Twixel/Team.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Newtonsoft.Json.Linq; 3 | 4 | namespace TwixelAPI 5 | { 6 | /// 7 | /// Team object 8 | /// 9 | public class Team : TwixelObjectBase 10 | { 11 | /// 12 | /// ID 13 | /// 14 | public long id; 15 | 16 | /// 17 | /// Name 18 | /// 19 | public string name; 20 | 21 | /// 22 | /// Info. 23 | /// Contains HTML tags by default. 24 | /// 25 | public string info; 26 | 27 | /// 28 | /// Display name 29 | /// 30 | public string displayName; 31 | 32 | /// 33 | /// Creation date 34 | /// 35 | public DateTime createdAt; 36 | 37 | /// 38 | /// Last updated 39 | /// 40 | public DateTime updatedAt; 41 | 42 | /// 43 | /// Link to logo 44 | /// 45 | public Uri logo; 46 | 47 | /// 48 | /// Link to banner 49 | /// 50 | public Uri banner; 51 | 52 | /// 53 | /// Link to background 54 | /// 55 | public Uri background; 56 | 57 | /// 58 | /// Team constructor 59 | /// 60 | /// ID 61 | /// Name 62 | /// Info 63 | /// Display name 64 | /// Creation date 65 | /// Last updated 66 | /// Link to logo 67 | /// Link to banner 68 | /// Link to background 69 | /// Twitch API version 70 | /// Base links JSON object 71 | public Team(long id, 72 | string name, 73 | string info, 74 | string displayName, 75 | string createdAt, 76 | string updatedAt, 77 | string logo, 78 | string banner, 79 | string background, 80 | Twixel.APIVersion version, 81 | JObject baseLinksO) : base(baseLinksO) 82 | { 83 | this.version = version; 84 | this.id = id; 85 | this.name = name; 86 | this.info = info; 87 | this.displayName = displayName; 88 | this.createdAt = DateTime.Parse(createdAt); 89 | this.updatedAt = DateTime.Parse(updatedAt); 90 | if (!string.IsNullOrEmpty(logo)) 91 | { 92 | this.logo = new Uri(logo); 93 | } 94 | if (!string.IsNullOrEmpty(banner)) 95 | { 96 | this.banner = new Uri(banner); 97 | } 98 | if (!string.IsNullOrEmpty(background)) 99 | { 100 | this.background = new Uri(background); 101 | } 102 | } 103 | 104 | /// 105 | /// Remove HTML tags and HTML decode info string 106 | /// 107 | public void CleanInfoString() 108 | { 109 | info = HelperMethods.ConvertAmp(HelperMethods.RemoveHtmlTags(info)).Trim(); 110 | char lastChar = '\0'; 111 | for (int i = 0; i < info.Length; i++) 112 | { 113 | if (info[i] == '\n') 114 | { 115 | if (lastChar == '\n') 116 | { 117 | i -= 1; 118 | info = info.Remove(i); 119 | break; 120 | } 121 | } 122 | lastChar = info[i]; 123 | } 124 | } 125 | } 126 | } 127 | -------------------------------------------------------------------------------- /Twixel.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.26228.4 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Twixel", "Twixel\Twixel.csproj", "{DFD0DB77-DBC7-4B79-8747-F9CAF6274DBE}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Twixel.Tests", "Twixel.Tests\Twixel.Tests.csproj", "{F7330052-1CA3-4B82-BC2A-3C962FD243B9}" 9 | EndProject 10 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "golf1052.Trexler", "..\Trexler\golf1052.Trexler\golf1052.Trexler.csproj", "{C9978181-B464-49F7-8FAB-6CA89B4293BB}" 11 | EndProject 12 | Global 13 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 14 | Debug|Any CPU = Debug|Any CPU 15 | Debug|ARM = Debug|ARM 16 | Debug|x64 = Debug|x64 17 | Debug|x86 = Debug|x86 18 | Release|Any CPU = Release|Any CPU 19 | Release|ARM = Release|ARM 20 | Release|x64 = Release|x64 21 | Release|x86 = Release|x86 22 | EndGlobalSection 23 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 24 | {DFD0DB77-DBC7-4B79-8747-F9CAF6274DBE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 25 | {DFD0DB77-DBC7-4B79-8747-F9CAF6274DBE}.Debug|Any CPU.Build.0 = Debug|Any CPU 26 | {DFD0DB77-DBC7-4B79-8747-F9CAF6274DBE}.Debug|ARM.ActiveCfg = Debug|Any CPU 27 | {DFD0DB77-DBC7-4B79-8747-F9CAF6274DBE}.Debug|x64.ActiveCfg = Debug|Any CPU 28 | {DFD0DB77-DBC7-4B79-8747-F9CAF6274DBE}.Debug|x86.ActiveCfg = Debug|Any CPU 29 | {DFD0DB77-DBC7-4B79-8747-F9CAF6274DBE}.Release|Any CPU.ActiveCfg = Release|Any CPU 30 | {DFD0DB77-DBC7-4B79-8747-F9CAF6274DBE}.Release|Any CPU.Build.0 = Release|Any CPU 31 | {DFD0DB77-DBC7-4B79-8747-F9CAF6274DBE}.Release|ARM.ActiveCfg = Release|Any CPU 32 | {DFD0DB77-DBC7-4B79-8747-F9CAF6274DBE}.Release|x64.ActiveCfg = Release|Any CPU 33 | {DFD0DB77-DBC7-4B79-8747-F9CAF6274DBE}.Release|x86.ActiveCfg = Release|Any CPU 34 | {F7330052-1CA3-4B82-BC2A-3C962FD243B9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 35 | {F7330052-1CA3-4B82-BC2A-3C962FD243B9}.Debug|Any CPU.Build.0 = Debug|Any CPU 36 | {F7330052-1CA3-4B82-BC2A-3C962FD243B9}.Debug|ARM.ActiveCfg = Debug|Any CPU 37 | {F7330052-1CA3-4B82-BC2A-3C962FD243B9}.Debug|x64.ActiveCfg = Debug|Any CPU 38 | {F7330052-1CA3-4B82-BC2A-3C962FD243B9}.Debug|x86.ActiveCfg = Debug|Any CPU 39 | {F7330052-1CA3-4B82-BC2A-3C962FD243B9}.Release|Any CPU.ActiveCfg = Release|Any CPU 40 | {F7330052-1CA3-4B82-BC2A-3C962FD243B9}.Release|Any CPU.Build.0 = Release|Any CPU 41 | {F7330052-1CA3-4B82-BC2A-3C962FD243B9}.Release|ARM.ActiveCfg = Release|Any CPU 42 | {F7330052-1CA3-4B82-BC2A-3C962FD243B9}.Release|x64.ActiveCfg = Release|Any CPU 43 | {F7330052-1CA3-4B82-BC2A-3C962FD243B9}.Release|x86.ActiveCfg = Release|Any CPU 44 | {C9978181-B464-49F7-8FAB-6CA89B4293BB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 45 | {C9978181-B464-49F7-8FAB-6CA89B4293BB}.Debug|Any CPU.Build.0 = Debug|Any CPU 46 | {C9978181-B464-49F7-8FAB-6CA89B4293BB}.Debug|ARM.ActiveCfg = Debug|Any CPU 47 | {C9978181-B464-49F7-8FAB-6CA89B4293BB}.Debug|ARM.Build.0 = Debug|Any CPU 48 | {C9978181-B464-49F7-8FAB-6CA89B4293BB}.Debug|x64.ActiveCfg = Debug|Any CPU 49 | {C9978181-B464-49F7-8FAB-6CA89B4293BB}.Debug|x64.Build.0 = Debug|Any CPU 50 | {C9978181-B464-49F7-8FAB-6CA89B4293BB}.Debug|x86.ActiveCfg = Debug|Any CPU 51 | {C9978181-B464-49F7-8FAB-6CA89B4293BB}.Debug|x86.Build.0 = Debug|Any CPU 52 | {C9978181-B464-49F7-8FAB-6CA89B4293BB}.Release|Any CPU.ActiveCfg = Release|Any CPU 53 | {C9978181-B464-49F7-8FAB-6CA89B4293BB}.Release|Any CPU.Build.0 = Release|Any CPU 54 | {C9978181-B464-49F7-8FAB-6CA89B4293BB}.Release|ARM.ActiveCfg = Release|Any CPU 55 | {C9978181-B464-49F7-8FAB-6CA89B4293BB}.Release|ARM.Build.0 = Release|Any CPU 56 | {C9978181-B464-49F7-8FAB-6CA89B4293BB}.Release|x64.ActiveCfg = Release|Any CPU 57 | {C9978181-B464-49F7-8FAB-6CA89B4293BB}.Release|x64.Build.0 = Release|Any CPU 58 | {C9978181-B464-49F7-8FAB-6CA89B4293BB}.Release|x86.ActiveCfg = Release|Any CPU 59 | {C9978181-B464-49F7-8FAB-6CA89B4293BB}.Release|x86.Build.0 = Release|Any CPU 60 | EndGlobalSection 61 | GlobalSection(SolutionProperties) = preSolution 62 | HideSolutionNode = FALSE 63 | EndGlobalSection 64 | EndGlobal 65 | -------------------------------------------------------------------------------- /Twixel.Tests/Twixelv3Tests.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using golf1052.Trexler; 5 | using Newtonsoft.Json.Linq; 6 | using TwixelAPI.Constants; 7 | using Xunit; 8 | 9 | namespace TwixelAPI.Tests 10 | { 11 | public class Twixelv3Tests 12 | { 13 | Twixel twixel; 14 | 15 | public Twixelv3Tests() 16 | { 17 | twixel = new Twixel(Secrets.ClientId, 18 | "http://golf1052.com", Twixel.APIVersion.v3); 19 | } 20 | 21 | [Fact] 22 | public async void ClientIdTest() 23 | { 24 | // This test doesn't pass https://discuss.dev.twitch.tv/t/problem-with-client-id/6528/2 25 | // You know...cause Twitch sucks 26 | string responseString = await Twixel.GetWebData(new Uri(new TrexUri(TwitchConstants.baseUrl)), Twixel.APIVersion.v3); 27 | JObject responseObject = JObject.Parse(responseString); 28 | bool identified = (bool)responseObject["identified"]; 29 | Assert.True(identified); 30 | } 31 | 32 | [Fact] 33 | public async void RetrieveChannelTest() 34 | { 35 | Channel golf1052 = await twixel.RetrieveChannel("golf1052"); 36 | Assert.Equal(22747608, golf1052.id); 37 | Assert.Equal("golf1052", golf1052.name); 38 | } 39 | 40 | [Fact] 41 | public async void RetrieveTeamsTest() 42 | { 43 | List teams = await twixel.RetrieveTeams("TSM_TheOddOne"); 44 | Team tsm = teams.FirstOrDefault((team) => team.name == "solomid"); 45 | Assert.NotNull(tsm); 46 | } 47 | 48 | [Fact] 49 | public async void RetrieveChatTest() 50 | { 51 | Dictionary chatLinks = await twixel.RetrieveChat("golf1052"); 52 | Assert.Equal(3, chatLinks.Count); 53 | } 54 | 55 | [Fact] 56 | public async void RetrieveEmoticonsTest() 57 | { 58 | List emotes = await twixel.RetrieveEmoticons(); 59 | Emoticon rotations = emotes.FirstOrDefault((emote) => emote.regex == "ognTSM"); 60 | Assert.NotNull(rotations); 61 | } 62 | 63 | [Fact] 64 | public async void RetrieveBadgesTest() 65 | { 66 | List badges = await twixel.RetrieveBadges("golf1052"); 67 | Assert.Equal(7, badges.Count); 68 | } 69 | 70 | [Fact] 71 | public async void RetrieveTopGamesTest() 72 | { 73 | Total> topGames = await twixel.RetrieveTopGames(); 74 | Game league = topGames.wrapped.FirstOrDefault((game) => game.name == "League of Legends"); 75 | Assert.NotNull(league); 76 | 77 | Total> nextGames = await twixel.RetrieveTopGames(25); 78 | league = nextGames.wrapped.FirstOrDefault((game) => game.name == "League of Legends"); 79 | Assert.Null(league); 80 | } 81 | 82 | [Fact] 83 | public async void RetrieveIngestsTest() 84 | { 85 | List ingests = await twixel.RetrieveIngests(); 86 | Ingest newYork = ingests.FirstOrDefault((ingest) => ingest.name == "US East: New York, NY"); 87 | Assert.NotNull(newYork); 88 | } 89 | 90 | [Fact] 91 | public async void SearchChannelsTest() 92 | { 93 | Total> searchedChannels = await twixel.SearchChannels("golf1052"); 94 | Channel channel = searchedChannels.wrapped.FirstOrDefault((c) => c.name == "golf1052"); 95 | Assert.NotNull(channel); 96 | } 97 | 98 | [Fact] 99 | public async void SearchStreamsTest() 100 | { 101 | Total> searchedStreams = await twixel.SearchStreams("league"); 102 | Stream leagueStream = searchedStreams.wrapped.FirstOrDefault((stream) => stream.game == "League of Legends"); 103 | Assert.NotNull(leagueStream); 104 | } 105 | 106 | [Fact] 107 | public async void SearchGamesTest() 108 | { 109 | List searchedGames = await twixel.SearchGames("League", true); 110 | SearchedGame league = searchedGames.FirstOrDefault((game) => game.name == "League of Legends"); 111 | Assert.NotNull(league); 112 | } 113 | 114 | [Fact] 115 | public async void RetrieveStreamTest() 116 | { 117 | bool streamOffline = false; 118 | Stream stream = null; 119 | // This stream may be offline so it is suggested you edit 120 | // this line to get a stream that is online. 121 | stream = await twixel.RetrieveStream("monstercat"); 122 | if (stream != null) 123 | { 124 | Assert.Equal("Music", stream.game); 125 | } 126 | else 127 | { 128 | Assert.True(streamOffline); 129 | } 130 | 131 | TwixelException ex = await Assert.ThrowsAsync(async () => await twixel.RetrieveStream("ETdfdsfjldsjdfs")); 132 | Assert.IsType(typeof(TwixelException), ex); 133 | 134 | ex = await Assert.ThrowsAsync(async () => await twixel.RetrieveStream("golf1052")); 135 | Assert.Equal("golf1052 is offline", ex.Message); 136 | } 137 | 138 | [Fact] 139 | public async void RetrieveStreamsTest() 140 | { 141 | Total> topStreams = await twixel.RetrieveStreams(); 142 | Assert.Equal(25, topStreams.wrapped.Count); 143 | 144 | Total> leagueStreams = await twixel.RetrieveStreams("League of Legends"); 145 | Assert.Equal("League of Legends", leagueStreams.wrapped[0].game); 146 | } 147 | 148 | [Fact] 149 | public async void RetrieveFeaturedStreamsTest() 150 | { 151 | List featuredStreams = await twixel.RetrieveFeaturedStreams(); 152 | foreach (FeaturedStream stream in featuredStreams) 153 | { 154 | stream.CleanTextString(); 155 | } 156 | Assert.True(featuredStreams.Count >= 5); 157 | } 158 | 159 | [Fact] 160 | public async void RetrieveStreamsSummaryTest() 161 | { 162 | Dictionary summary = await twixel.RetrieveStreamsSummary(); 163 | Assert.True(summary["Viewers"] > 1); 164 | Assert.True(summary["Channels"] > 1); 165 | } 166 | 167 | [Fact] 168 | public async void RetrieveAllTeamsTest() 169 | { 170 | List teams = await twixel.RetrieveTeams(); 171 | Team staff = teams.FirstOrDefault((team) => team.name == "staff"); 172 | Assert.NotNull(staff); 173 | } 174 | 175 | [Fact] 176 | public async void RetrieveTeamTest() 177 | { 178 | Team staff = await twixel.RetrieveTeam("staff"); 179 | Assert.Equal("staff", staff.name); 180 | } 181 | 182 | [Fact] 183 | public async void RetrieveUserTest() 184 | { 185 | User golf1052 = await twixel.RetrieveUser("golf1052"); 186 | Assert.Equal("golf1052", golf1052.displayName); 187 | } 188 | 189 | [Fact] 190 | public async void RetrieveVideoTest() 191 | { 192 | Video video = await twixel.RetrieveVideo("v50248541"); 193 | Assert.Equal(27, video.length); 194 | Assert.Equal("League of Legends", video.game); 195 | } 196 | 197 | [Fact] 198 | public async void RetrieveTopVideosTest() 199 | { 200 | List