-
Notifications
You must be signed in to change notification settings - Fork 2
/
pal_template.txt
165 lines (140 loc) · 5.35 KB
/
pal_template.txt
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
{**
* SAM Broadcaster Web2.0 Connector (/**FB_TWEET**/)
*
* @copyright 2011 by Benedikt Bauer | http://www.sam-song.info
* @version 11.07-11b
* @link http://www.sam-song.info
* @author Benedikt Bauer
*
* @license
* The contents of this file are subject to the
* DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
* Version 2, December 2004
*
* Copyright for this License (C) 2004 Sam Hocevar <[email protected]>
*
* Everyone is permitted to copy and distribute verbatim or modified
* copies of this license document, and changing it is allowed as long
* as the name is changed.
*
* DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
* TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
*
* 0. You just DO WHAT THE FUCK YOU WANT TO.
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
*}
/////////////////////////////////////////////////////////////////////
// Nettiquette //
// You may use this PAL Script to communicate with my server //
// Change it to your like but don't flood the server/network //
// //
// Also make sure you don't post any inappropriate messages //
// Either me or twitter/fb might then cease to run this service //
// //
// This service has no guaranteed uptime nor support //
// However you may ask Questions in the Spacialaudio Forums //
// I will probably come back to you and help //
// //
// The Webservice will stay private //
// At least until its completely done and tidied up //
// //
// //
// Don't make any changes outside of boxes like this //
// unless you really know what you do. //
// I won't give any support if you changed something //
// you better shouldn't have touched //
// //
/////////////////////////////////////////////////////////////////////
{Declaration (Variables)}
var Player : TPlayer;
var Song : TSongInfo;
var statusmessage, returnmessage, picture : String;
var ErrorLog, DebugLog : String;
{Declaration (Functions and Procedures)}
// Construct the GET String for the Web Script, call it and return the output
FUNCTION update(status, picture : String) : String; forward;
// Write Error / Debug Log
PROCEDURE WriteLog(msg : String; error : boolean); forward;
// BEGIN MAIN
PAL.Loop := True;
/**Replace_Interval**/
// reliably detect ActivePlayer (needed for SAM <= 4.9.0, fixed in 4.9.1)
PAL.LockExecution;
IF (DeckA.Duration - DeckA.CurTime) >= (DeckB.Duration - DeckB.CurTime) THEN
Player := DeckA
ELSE
Player := DeckB;
PAL.UnlockExecution;
// SAM >= 4.9.1 can use this one:
//Player := ActivePlayer;
// Is anything playing right now?
IF ( Player <> NIL ) THEN
BEGIN
Song := Player.GetSongInfo;
IF (Song <> NIL) AND (Pos(Song['songtype'],'/**Song_Types**/') > 0) THEN
BEGIN
// Message to display in /**FB_TWEET**/
statusmessage := /**First_Field**/ + ' - ' + /**Second_Field**/;
picture := Song['picture'];
IF Pos('jpg', picture) = 0 THEN
BEGIN
picture := 'na.gif'
END;
returnmessage := update(statusmessage, picture);
// Errormessages don't contain the underscore
IF ( Pos('##', returnmessage) = 0 ) THEN
BEGIN
WriteLog(returnmessage, TRUE)
END
// For debugging purposes Successful Posts will be logged as well
ELSE
WriteLog(returnmessage, FALSE);
END;
END;
Song.Free;
Player.Free;
// END MAIN
FUNCTION update(status, picture : String) : String;
var getstr,returnstr : String;
BEGIN
// URLEncode Blanks and Special Chars
status := URLEncode(status);
picture := URLEncode(picture);
getStr := 'http://sam-song.info//**FB_TWEET**//'
+ '?message=' + status + '&userid=/**USER_ID**/'
/**PICTURE**/;
WriteLog(getStr, FALSE);
// Here goes the magic!
returnstr := WebToStr(getStr);
result := returnstr;
END;
PROCEDURE WriteLog(msg : String; error : boolean);
BEGIN
IF NOT SetCurrentDir('C:\sam-song.info') THEN
BEGIN
CreateDir('C:\sam-song.info');
SetCurrentDir('C:\sam-song.info');
END;
PAL.LockExecution;
msg := DateTimeToStr(NOW) + ' ' + msg + chr(13) + chr(10);
Writeln(msg);
IF error THEN
BEGIN
//ERROR LOG create if not exists
IF FileExists('/**FB_TWEET**/-error.log') THEN
AppendStringToFile('/**FB_TWEET**/-error.log', msg)
ELSE
SaveStringToFile('/**FB_TWEET**/-error.log', msg)
END
ELSE
BEGIN
//DEBUG LOG create if not exists
IF FileExists('/**FB_TWEET**/-debug.log') THEN
AppendStringToFile('/**FB_TWEET**/-debug.log', msg)
ELSE
SaveStringToFile('/**FB_TWEET**/-debug.log', msg);
END;
PAL.UnlockExecution;
END;