daily pastebin goal
46%
SHARE
TWEET

Twitch.tv Status

ShadowTzu Jan 18th, 2015 276 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 'Coded by ShadowTzu
  2. 'Free to use
  3.  
  4. 'my 3D engine, Tzu3D: http://shadowtzu.free.fr
  5. 'Youtube: https://www.youtube.com/user/shadowtzu
  6. 'Facebook: https://www.facebook.com/Tzu3d
  7. 'Twitter: https://twitter.com/shadowtzu
  8. 'Twitch: http://www.twitch.tv/shadowtzu
  9. 'Website: http://tzu3d.weebly.com
  10.  
  11. Imports System.Net
  12. Public Class Twitch
  13.     Implements IDisposable
  14.  
  15.     Private mDataPage As String
  16.     Private Web As Net.WebClient
  17.     Private Splitted() As String
  18.  
  19.     Public Sub New()
  20.         Web = New WebClient
  21.         Web.Proxy = Nothing
  22.         Web.Encoding = System.Text.Encoding.UTF8
  23.     End Sub
  24.  
  25.     Public Sub Load(user As String)
  26.  
  27.         mDataPage = Web.DownloadString("https://api.twitch.tv/kraken/streams/" & user)
  28.         Splitted = Split(mDataPage, """:")
  29.  
  30.     End Sub
  31.  
  32.     Public ReadOnly Property IsOnline() As Boolean
  33.         Get
  34.             If Splitted(4).StartsWith("null") Then
  35.                 Return False
  36.             Else
  37.                 Return True
  38.             End If
  39.         End Get
  40.     End Property
  41.  
  42.     Public ReadOnly Property Game() As String
  43.         Get
  44.             If IsOnline Then
  45.                 Dim clean As String = Split(Splitted(6), """")(1)
  46.  
  47.                 Return clean
  48.             End If
  49.             Return ""
  50.         End Get
  51.     End Property
  52.  
  53.     Public ReadOnly Property View() As String
  54.         Get
  55.             If IsOnline Then
  56.                 Dim clean As String = Split(Splitted(7), """")(0).Replace(",", "")
  57.                 Return clean
  58.             End If
  59.             Return ""
  60.         End Get
  61.     End Property
  62.  
  63.     Public ReadOnly Property Started() As String
  64.         Get
  65.             If IsOnline Then
  66.                 Dim clean As String = Split(Splitted(8), """")(1).Replace(",", "")
  67.                 Return clean
  68.             End If
  69.             Return ""
  70.         End Get
  71.     End Property
  72.  
  73.     Public ReadOnly Property Preview() As String
  74.         Get
  75.             If IsOnline Then
  76.                 Dim clean As String = Split(Splitted(14), """")(1).Replace(",", "")
  77.                 Return clean
  78.             End If
  79.             Return ""
  80.         End Get
  81.     End Property
  82.  
  83.     Public ReadOnly Property Logo() As String
  84.         Get
  85.             If IsOnline Then
  86.                 Dim clean As String = Split(Splitted(33), """")(1).Replace(",", "")
  87.                 Return clean
  88.             End If
  89.             Return ""
  90.         End Get
  91.     End Property
  92.  
  93.     Public ReadOnly Property Title() As String
  94.         Get
  95.             If IsOnline Then
  96.                 Dim clean As String = Split(Splitted(35), """")(1).Replace(",", "")
  97.                 Return clean
  98.             End If
  99.             Return ""
  100.         End Get
  101.     End Property
  102.  
  103.     Public ReadOnly Property Banner_Offline() As String
  104.         Get
  105.             If IsOnline Then
  106.                 Dim clean As String = Split(Splitted(38), """")(1).Replace(",", "")
  107.                 Return clean
  108.             End If
  109.             Return ""
  110.         End Get
  111.     End Property
  112.  
  113.     Public ReadOnly Property User_ID() As String
  114.         Get
  115.             If IsOnline Then
  116.                 Dim clean As String = Split(Splitted(39), """")(0).Replace(",", "")
  117.                 Return clean
  118.             End If
  119.             Return ""
  120.         End Get
  121.     End Property
  122.  
  123.     Public ReadOnly Property Created() As String
  124.         Get
  125.             If IsOnline Then
  126.                 Dim clean As String = Split(Splitted(41), """")(1).Replace(",", "")
  127.                 Return clean
  128.             End If
  129.             Return ""
  130.         End Get
  131.     End Property
  132.  
  133.     Public ReadOnly Property Updated() As String
  134.         Get
  135.             If IsOnline Then
  136.                 Dim clean As String = Split(Splitted(42), """")(1).Replace(",", "")
  137.                 Return clean
  138.             End If
  139.             Return ""
  140.         End Get
  141.     End Property
  142.  
  143.     Public ReadOnly Property Follower() As String
  144.         Get
  145.             If IsOnline Then
  146.                 Dim clean As String = Split(Splitted(44), """")(0).Replace(",", "")
  147.                 Return clean
  148.             End If
  149.             Return ""
  150.         End Get
  151.     End Property
  152.  
  153.     Public ReadOnly Property User_banner() As String
  154.         Get
  155.             If IsOnline Then
  156.                 Dim clean As String = Split(Splitted(45), """")(1).Replace(",", "")
  157.                 Return clean
  158.             End If
  159.             Return ""
  160.         End Get
  161.     End Property
  162.  
  163.     Public ReadOnly Property TotalView() As String
  164.         Get
  165.             If IsOnline Then
  166.                 Dim clean As String = Split(Splitted(47), """")(0).Replace(",", "")
  167.                 Return clean
  168.             End If
  169.             Return ""
  170.         End Get
  171.     End Property
  172.  
  173.     Public ReadOnly Property Language() As String
  174.         Get
  175.             If IsOnline Then
  176.                 Dim clean As String = Split(Splitted(48), """")(1).Replace(",", "")
  177.                 Return clean
  178.             End If
  179.             Return ""
  180.         End Get
  181.     End Property
  182. #Region "IDisposable Support"
  183.     Private disposedValue As Boolean
  184.  
  185.     Protected Overridable Sub Dispose(disposing As Boolean)
  186.         If Not Me.disposedValue Then
  187.             If disposing Then
  188.                 Web.Dispose()
  189.                 Web = Nothing
  190.             End If
  191.  
  192.         End If
  193.         Me.disposedValue = True
  194.     End Sub
  195.  
  196.     Public Sub Dispose() Implements IDisposable.Dispose
  197.         Dispose(True)
  198.         GC.SuppressFinalize(Me)
  199.     End Sub
  200. #End Region
  201.  
  202. End Class
RAW Paste Data
Top