-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
341 lines (297 loc) · 8.02 KB
/
main.cpp
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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
#include <fstream>
#include <iostream>
#include <sstream>
#include <string>
#include <cstdio>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int git_pull(){
char psBuffer[1024];
FILE *pPipe;
//ofstream gitlogfile("gitaddlog.txt");
#ifdef WIN32
if( (pPipe = _popen("git pull origin", "rb" )) == NULL )
return( 1 );
#elif __linux__
if( (pPipe = popen("git pull origin", "r" )) == NULL )
return( 1 );
#endif
while(fgets(psBuffer, 1024, pPipe))
{
puts(psBuffer);
//gitlogfile << psBuffer << endl;
}
//gitlogfile.close();
if (feof( pPipe))
{
#ifdef WIN32
printf( "\nProcess returned %d\n", _pclose( pPipe ) );
#elif __linux__
printf( "\nProcess returned %d\n", pclose( pPipe ) );
#endif
}
else
{
printf( "Error: Failed to read the pipe to the end.\n");
}
return 0;
}
int git_add(){
char psBuffer[1024];
FILE *pPipe;
//ofstream gitlogfile("gitaddlog.txt");
#ifdef WIN32
if( (pPipe = _popen("git add .", "rb" )) == NULL )
return( 1 );
#elif __linux__
if( (pPipe = popen("git add .", "r" )) == NULL )
return( 1 );
#endif
while(fgets(psBuffer, 1024, pPipe))
{
puts(psBuffer);
//gitlogfile << psBuffer << endl;
}
//gitlogfile.close();
if (feof( pPipe))
{
#ifdef WIN32
printf( "\nProcess returned %d\n", _pclose( pPipe ) );
#elif __linux__
printf( "\nProcess returned %d\n", pclose( pPipe ) );
#endif
}
else
{
printf( "Error: Failed to read the pipe to the end.\n");
}
return 0;
}
int git_commit(){
char psBuffer[1024];
FILE *pPipe;
//ofstream gitlogfile("gitcommitlog.txt");
#ifdef WIN32
if( (pPipe = _popen("git commit -m \"auto update service\"", "rb" )) == NULL )
return( 1 );
#elif __linux__
if( (pPipe = popen("git commit -m \"auto update service\"", "r" )) == NULL )
return( 1 );
#endif
while(fgets(psBuffer, 1024, pPipe))
{
puts(psBuffer);
// gitlogfile << psBuffer << endl;
}
//gitlogfile.close();
if (feof( pPipe))
{
#ifdef WIN32
printf( "\nProcess returned %d\n", _pclose( pPipe ) );
#elif __linux__
printf( "\nProcess returned %d\n", pclose( pPipe ) );
#endif
}
else
{
printf( "Error: Failed to read the pipe to the end.\n");
}
return 0;
}
int git_push(){
char psBuffer[1024];
FILE *pPipe;
//ofstream gitlogfile("gitpushlog.txt");
#ifdef WIN32
if( (pPipe = _popen("git push origin", "rb" )) == NULL )
return( 1 );
#elif __linux__
if( (pPipe = popen("git push origin", "r" )) == NULL )
return( 1 );
#endif
while(fgets(psBuffer, 1024, pPipe))
{
puts(psBuffer);
// gitlogfile << psBuffer << endl;
}
//gitlogfile.close();
if (feof( pPipe))
{
#ifdef WIN32
printf( "\nProcess returned %d\n", _pclose( pPipe ) );
#elif __linux__
printf( "\nProcess returned %d\n", pclose( pPipe ) );
#endif
}
else
{
printf( "Error: Failed to read the pipe to the end.\n");
}
return 0;
}
int update_url(string neturl, int linenum) {
char psBuffer[32768];
FILE *pPipe;
string str;
ifstream infile("iptv.m3u");
ofstream tempfile("temp.txt");
if (!infile) {
printf("Error! File not found.");
return 1;
}
for(int i=0; i < linenum - 1; i++) {
getline(infile,str);
tempfile << str << endl;
//cout << str << endl;
}
string cmdnet = "youtube-dl -f 94 -g ";
cmdnet += neturl;
#ifdef _WIN32
if( (pPipe = _popen(cmdnet.c_str(), "rb" )) == NULL )
return( 1 );
#elif __linux__
printf("Starting youtube-dl...");
if( (pPipe = popen(cmdnet.c_str(), "r" )) == NULL )
return( 1 );
#endif
while(fgets(psBuffer, 32768, pPipe))
{
puts(psBuffer);
//cout << "\n Output is:\n";
string t(psBuffer);
if (!t.empty() && t[t.length()-1] == '\n') {
t.erase(t.length()-1);
}
t += "|Referer=";
t += neturl;
//cout << t << "\n";
tempfile << t << endl;
getline(infile,str);
}
while(getline(infile,str)) {
tempfile << str << endl;
//cout << str << endl;
}
// close file
infile.close();
tempfile.close();
remove("iptv.m3u");
rename("temp.txt", "iptv.m3u");
remove("temp.txt");
if (feof( pPipe))
{
#ifdef WIN32
printf( "\nProcess returned %d\n", _pclose( pPipe ) );
#elif __linux__
printf( "\nProcess returned %d\n", pclose( pPipe ) );
#endif
}
else
{
printf( "Error: Failed to read the pipe to the end.\n");
}
return 0;
}
int update_dm(string dmurl, int linenum) {
char psBuffer[32768];
FILE *pPipe;
string str;
ifstream infile("iptv.m3u");
ofstream tempfile("temp.txt");
if (!infile) {
printf("Error! File not found.");
return 1;
}
for(int i=0; i < linenum - 1; i++) {
getline(infile,str);
tempfile << str << endl;
//cout << str << endl;
}
string cmdnet = "youtube-dl -f hls-480-0 -g ";
cmdnet += dmurl;
#ifdef _WIN32
if( (pPipe = _popen(cmdnet.c_str(), "rb" )) == NULL )
return( 1 );
#elif __linux__
printf("Starting youtube-dl...");
if( (pPipe = popen(cmdnet.c_str(), "r" )) == NULL )
return( 1 );
#endif
while(fgets(psBuffer, 32768, pPipe))
{
puts(psBuffer);
//cout << "\n Output is:\n";
string t(psBuffer);
if (!t.empty() && t[t.length()-1] == '\n') {
t.erase(t.length()-1);
}
t += "|Referer=";
t += dmurl;
//cout << t << "\n";
tempfile << t << endl;
getline(infile,str);
}
while(getline(infile,str)) {
tempfile << str << endl;
//cout << str << endl;
}
// close file
infile.close();
tempfile.close();
remove("iptv.m3u");
rename("temp.txt", "iptv.m3u");
remove("temp.txt");
if (feof( pPipe))
{
#ifdef WIN32
printf( "\nProcess returned %d\n", _pclose( pPipe ) );
#elif __linux__
printf( "\nProcess returned %d\n", pclose( pPipe ) );
#endif
}
else
{
printf( "Error: Failed to read the pipe to the end.\n");
}
return 0;
}
int main(int argc, char** argv) {
const string url1 = "https://www.youtube.com/channel/UCcZg5r9hBqK_VPUT2I7eYVw/live"; //bernama
const string url2 = "https://www.youtube.com/channel/UCQo_L_h_01NjLYiNHUnjEJw/live"; //reformed21
const string url3 = "https://www.youtube.com/channel/UCTR1wO3hnYzBs0BJIQAyZKw/live"; //hope channel
const string url4 = "https://www.youtube.com/channel/UCER4rvDnRBPr_ncYW4UCZjg/live"; //tvone
const string url5 = "https://www.youtube.com/channel/UC5BMIWZe9isJXLZZWPWvBlg/live"; //kompastv
const string url6 = "https://www.youtube.com/channel/UC1-ATnDVEwKT6-0aEeJ2ibA/live"; //net
const string url7 = "https://www.youtube.com/channel/UCzVtD2LBJ29L6Tz4YzLLAcg/live"; //gprtv
const string url8 = "https://www.youtube.com/channel/UCoMdktPbSTixAyNGwb-UYkQ/live"; //skynews
const string url9 = "https://www.youtube.com/channel/UCSrZ3UV4jOidv8ppoVuvW9Q/live"; //euronews
const string url10 = "https://www.youtube.com/channel/UC4K_LI-Tn3-LshNgG0-YypQ/live"; //cctv4
const string url11 = "https://www.dailymotion.com/embed/video/kxm1wihUkjNiINrAqlg"; //ntv7
const string url12 = "https://www.dailymotion.com/embed/video/kdFzSYy1bHxrForBrar"; //8tv
const string url13 = "https://www.dailymotion.com/embed/video/k1FijVynGNsZ2ZrAGJ0"; //tv9
const string url14 = "https://www.youtube.com/channel/UCWw_gejTX29Yn89LLpcINZQ/live"; //kbs world
const string url15 = "https://www.youtube.com/channel/UCf1y3FvYJYPbgMqHX7ZzeZA/live"; //sbn us
const string url16 = "https://www.youtube.com/channel/UC7E-LYc1wivk33iyt5bR5zQ/live"; //vaticanmedia
printf("Starting update URL proccess...");
update_url(url1,160);
update_url(url2,112);
update_url(url3,109);
update_url(url4,106);
update_url(url5,103);
//update_url(url6,91);
update_url(url7,76);
update_url(url8,196);
update_url(url9,223);
update_url(url10,226);
update_dm(url11,229);
update_dm(url12,232);
update_dm(url13,235);
update_url(url14,238);
update_url(url15,241);
update_url(url16,253);
git_add();
git_commit();
git_push();
printf("Update URL proccess complete!");
return 0;
}