-
Notifications
You must be signed in to change notification settings - Fork 0
/
grooveshark.php
executable file
·112 lines (92 loc) · 2.65 KB
/
grooveshark.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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
<?php
require_once ('groovesharkdb.php');
require_once ('sessiondata.php');
class Grooveshark
{
#region Public Properties
public $SessionData;
public $Token;
#endregion
#region Private Members
private $_dbConnection;
#endregion
#region Constructor(s)
public function __construct()
{
$this->_dbConnection = new GroovesharkDatabase(
$cfg['db']['host'],
$cfg['db']['dbase'],
$cfg['db']['user'],
$cfg['db']['pass']
);
$this->initialize();
}
#endregion
#region Public Functions
public function somethingToDoWithGettingAllBroadcastData()
{
if ($this->SessionData == null)
throw new Exception("SessionData is not available.");
if ($this->Token == null)
throw new Exception("Token is not available.");
// get users
// loop through users
// get data for user
}
#endregion
#region Private Functions
private function initialize()
{
$sessionData = $this->_dbConnection->getSessionData();
if (sessionData == null)
{
// No session data has been cached yet, get it
$sessionData = $this->getSessionDataFromWeb();
}
if ($sessionData != null)
{
$token = $this->getTokenFromWeb($sessionData);
if ($token == null)
{
$sessionData = $this->getSessionDataFromWeb();
$token = $this->getTokenFromWeb($sessionData);
}
if ($token == null)
{
// Give up, cry, log messages.
}
else
{
$this->SessionData = $sessionData;
$this->Token = $token;
}
}
}
private function getSessionDataFromWeb()
{
$sessionData = null;
// $sessionData = $this->gsWebInterface->QuerySessionData();
if ($sessionData == null)
{
// Trigger some failure
// Email?
}
else
{
$this->_dbConnection->saveSessionData($sessionData);
}
return $sessionData;
}
private function getTokenFromWeb()
{
$token = null;
// MAGIC!
return $token;
}
#endregion
// public function getBroadcastData($sessionData)
// {
// $data = "";
// return $data;
// }
}