forked from sunsettrack4/zattoo_tvh
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ztvh.sh
2664 lines (2280 loc) · 87.8 KB
/
ztvh.sh
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
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/bin/bash
# Copyright (C) 2017-2018 Jan-Luca Neumann
# https://github.com/sunsettrack4/zattoo_tvh/
#
# This Program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# This Program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with zattoo_tvh. If not, see <http://www.gnu.org/licenses/>.
clear
echo " "
echo "ZattooUNLIMITED for VLC and tvheadend "
echo "(c) 2017-2018 Jan-Luca Neumann I + "
echo "Script v0.5.0 2018/12/16 | Zattoo v2.12.9 I I + "
echo " I I + "
echo " II "
echo "ZZZZZZZZZ AA TTTTTTTTTT TTTTTTTTTT 888888 888888 "
echo " ZZ AA TT TT 88 88 88 88 "
echo " ZZ A A TT TT 88 88 88 88 "
echo " ZZ AA AA TT TT 88 888 88"
echo " ZZ AAAAAAAA TT TT 88 888 88"
echo " ZZ AA AA TT TT 88 88 88 88 "
echo " ZZ AA AA TT TT 88 88 88 88 "
echo "ZZZZZZZZZ AA AA TT TT 888888 888888 "
echo ""
echo " ~ WATCH YOU WANT ~"
echo ""
# ##################
# CHECK CONDITIONS #
# ##################
#
# Existence of required programs
#
command -v dialog >/dev/null 2>&1 || { echo "dialog is required but it's not installed! Aborting." >&2; exit 1; }
command -v curl >/dev/null 2>&1 || { echo "curl is required but it's not installed! Aborting." >&2; exit 1; }
command -v phantomjs >/dev/null 2>&1 || { echo "PhantomJS is required but it's not installed! Aborting." >&2; exit 1; }
command -v uni2ascii >/dev/null 2>&1 || { echo "uni2ascii is required but it's not installed! Aborting." >&2; exit 1; }
command -v xmllint >/dev/null 2>&1 || { echo "libxml2-utils is required but it's not installed! Aborting." >&2; exit 1; }
command -v ffmpeg >/dev/null 2>&1 || { echo "ffmpeg is required for watching Live TV but it's not installed!" && sleep 1s; }
command -v vlc >/dev/null 2>&1 || { echo "VLC is required but for watching Live TV on desktop but it's not installed!" && sleep 1s; }
printf "Starting script..."
sleep 2s
#
# Existence of internet connectivity
#
if ! ping -q -w 1 -c 1 `ip r | grep default | cut -d ' ' -f 3` > /dev/null 2> /dev/null
then
printf "\r- ERROR: NO INTERNET CONNECTION AVAILABLE! -\n"
exit 1
else
curl --silent -H "user-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36" https://goo.gl/iyX1KE > /dev/null
fi
#
# Existence of all required scripts and its executable permissions
#
# FOLDER + FILES missing
if ls -ld ~/ztvh | grep -q "drwxrwxrwx" 2> /dev/null
then
cd ~/ztvh
elif [ -e ~/ztvh ]
then
printf "\r- ERROR: SCRIPT FOLDER DOES NOT HAVE THE CORRECT PERMISSION VALUES! -\n"
if chmod 0777 ~/ztvh 2> /dev/null
then
echo "Permission issue fixed, please restart the script to proceed."
fi
exit 1
else
printf "\r- ERROR: SCRIPT FOLDER NOT EXISTING IN HOME DIRECTORY! -\n"
exit 1
fi
# FILES missing
if [ ! -e ztvh.sh ]
then
printf "\r- ERROR: MAIN SCRIPT MUST BE LOCATED IN MAIN FOLDER! -\n"
exit 1
elif [ ! -x ztvh.sh ]
then
printf "\r- ERROR: MAIN SCRIPT IS NOT EXECUTABLE! -\n"
if chmod 0777 ztvh.sh 2> /dev/null
then
echo "Permission issue fixed, please restart the script to proceed."
fi
exit 1
fi
if chmod 0777 ~/ztvh/* 2> /dev/null
then :
else
printf "\r- WARNING: FILE PERMISSIONS COULD NOT BE SET! -\n"
fi
if [ ! -e save_page.js ]
then
printf "\rMissing file: save_page.js\n"
touch fakefile
elif [ ! -x save_page.js ]
then
printf "\rFile not executable: savepage.js\n"
touch fakefile
fi
if [ ! -e zguide_dl.sh ]
then
printf "\rMissing file: zguide_dl.sh\n"
touch fakefile
elif [ ! -x zguide_dl.sh ]
then
printf "\rFile not executable: zguide_dl.sh\n"
touch fakefile
fi
if [ ! -e zguide_fc.sh ]
then
printf "\rMissing file: zguide_fc.sh\n"
touch fakefile
elif [ ! -x zguide_fc.sh ]
then
printf "\rFile not executable: zguide_fc.sh\n"
touch fakefile
fi
if [ ! -e zguide_pc.sh ]
then
printf "\rMissing file: zguide_pc.sh\n"
touch fakefile
elif [ ! -x zguide_pc.sh ]
then
printf "\rFile not executable: zguide_pc.sh\n"
touch fakefile
fi
if [ ! -e zguide_su.sh ]
then
printf "\rMissing file: zguide_su.sh\n"
touch fakefile
elif [ ! -x zguide_su.sh ]
then
printf "\rFile not executable: zguide_su.sh\n"
touch fakefile
fi
if [ ! -e zguide_xmltv.sh ]
then
printf "\rMissing file: zguide_xmltv.sh\n"
touch fakefile
elif [ ! -x zguide_xmltv.sh ]
then
printf "\rFile not executable: zguide_xmltv.sh\n"
touch fakefile
fi
if [ ! -e zguide_xmltv_simple.sh ]
then
printf "\rMissing file: zguide_xmltv_simple.sh\n"
touch fakefile
elif [ ! -x zguide_xmltv_simple.sh ]
then
printf "\rFile not executable: zguide_xmltv_simple.sh\n"
touch fakefile
fi
if [ ! -e pipe.sh ]
then
printf "\rMissing file: pipe.sh\n"
touch fakefile
elif [ ! -r pipe.sh ]
then
printf "\rFile not readable: pipe.sh\n"
touch fakefile
fi
if [ ! -e status.sh ]
then
printf "\rMissing file: status.sh\n"
touch fakefile
elif [ ! -x status.sh ]
then
printf "\rFile not executable: status.sh\n"
touch fakefile
fi
if [ ! -e live.sh ]
then
printf "\rMissing file: live.sh\n"
touch fakefile
elif [ ! -x live.sh ]
then
printf "\rFile not executable: live.sh\n"
touch fakefile
fi
if [ ! -e recordings.sh ]
then
printf "\rMissing file: recordings.sh\n"
touch fakefile
elif [ ! -x recordings.sh ]
then
printf "\rFile not executable: recordings.sh\n"
touch fakefile
fi
# if [ ! -e txt.sh ]
# then
# printf "\rMissing file: txt.sh\n"
# touch fakefile
# elif [ ! -x txt.sh ]
# then
# printf "\rFile not executable: txt.sh\n"
# touch fakefile
# fi
if [ -e fakefile ]
then
printf "\r- ERROR: FAILED TO LOAD REQUIRED SCRIPT(S)! -\n"
rm fakefile
exit 1
fi
#
# Further actions
#
export QT_QPA_PLATFORM=offscreen
rm -rf work 2> /dev/null
mkdir work
chmod 0777 work
mkdir user 2> /dev/null
chmod 0777 user
# ###############
# LOGIN PROCESS #
# ###############
cd work
echo "MENU" > value
# retrieve user data
until grep -q '"success": true' login.txt 2> /dev/null
do
mkdir ~/ztvh/user 2> /dev/null
touch ~/ztvh/user/userfile
if tr '\n' ' ' < ~/ztvh/user/userfile | grep "provider" | grep "login" | grep -q "password"
then
if grep -q "insecure=ask" ~/ztvh/user/userfile
then
dialog --backtitle "[L41A0] ZATTOO UNLIMITED BETA > LOGIN" --title "[2] WARNING" --infobox "Please note that the server verification failed last time.\nYou can still connect to the IPTV web service, but the server can't be verified as secure due to a problem with the certificate.\n\nMore information: https://curl.haxx.se/docs/sslcerts.html\n\nPress [ENTER] to disable SSL verification.\nScript will proceed in 10 seconds." 13 70
if read -t 10 -n1
then
sed -i "s/insecure=ask/insecure=true/g" ~/ztvh/user/userfile
else
sed -i "/insecure=ask/d" ~/ztvh/user/userfile
fi
fi
if grep -q "insecure=true" ~/ztvh/user/userfile
then
dialog --backtitle "[L41A0] [INSECURE] ZATTOO UNLIMITED BETA > LOGIN" --title "[1] WARNING" --infobox "SSL verification disabled!" 3 40
sleep 3s
dialog --backtitle "[L41W0] [INSECURE] ZATTOO UNLIMITED BETA > LOGIN" --title "LOGIN" --infobox "Login to webservice..." 3 40
else
dialog --backtitle "[L41W0] ZATTOO UNLIMITED BETA > LOGIN" --title "LOGIN" --infobox "Login to webservice..." 3 40
fi
provider=$(sed "2,5d;s/provider=//g" ~/ztvh/user/userfile)
if [ -e ~/ztvh/user/session ]
then
session=$(<~/ztvh/user/session)
fi
if grep -q "insecure=true" ~/ztvh/user/userfile
then
curl -k -i -X POST -H "Content-Type: application/x-www-form-urlencoded" -H "Accept: application/x-www-form-urlencoded" -v --cookie "$session" --data-urlencode "$(grep 'login=' ~/ztvh/user/userfile)" --data-urlencode "$(grep 'password=' ~/ztvh/user/userfile)" https://$provider/zapi/v2/account/login > login.txt 2> /dev/null
else
curl -i -X POST -H "Content-Type: application/x-www-form-urlencoded" -H "Accept: application/x-www-form-urlencoded" -v --cookie "$session" --data-urlencode "$(grep 'login=' ~/ztvh/user/userfile)" --data-urlencode "$(grep 'password=' ~/ztvh/user/userfile)" https://$provider/zapi/v2/account/login > login.txt 2> /dev/null
fi
if grep -q '"success": true' login.txt
then
sed '/Set-cookie/!d' login.txt > workfile
sed -i 's/expires.*//g' workfile
sed -i 's/Set-cookie: //g' workfile
sed -i 's/Set-cookie: //g' workfile
tr -d '\n' < workfile > ~/ztvh/user/session
sed -i 's/; Path.*//g' ~/ztvh/user/session
session=$(<~/ztvh/user/session)
sleep 1s
elif grep -q '400 Bad Request' login.txt
then
if grep -q "insecure=true" ~/ztvh/user/userfile
then
dialog --backtitle "[L41E0] [INSECURE] ZATTOO UNLIMITED BETA > LOGIN" --title "ERROR" --infobox "Login failed!\n\nPress [1] to enter new password or\n [2] to logout and delete all data.\n\nWindow will be closed in 10 seconds." 8 50
else
dialog --backtitle "[L41E0] ZATTOO UNLIMITED BETA > LOGIN" --title "ERROR" --infobox "Login failed!\n\nPress [1] to enter new password or\n [2] to logout and delete all data.\n\nWindow will be closed in 10 seconds." 8 50
fi
read -t 10 -n1 n
echo "EXIT" > fakefile
case $n in
1) if grep -q "insecure=true" ~/ztvh/user/userfile
then
password=$(dialog --backtitle "[L4100] [INSECURE] ZATTOO UNLIMITED BETA > LOGIN" --title "PASSWORD" --passwordbox "Please enter your (new) password.\nPress [ESC] or cancel to exit the script." 8 50 3>&1 1>&2 2>&3 3>&-)
else
password=$(dialog --backtitle "[L4100] ZATTOO UNLIMITED BETA > LOGIN" --title "PASSWORD" --passwordbox "Please enter your (new) password.\nPress [ESC] or cancel to exit the script." 8 50 3>&1 1>&2 2>&3 3>&-)
fi
if test $? -eq 0
then
sed -i "/password=/d" ~/ztvh/user/userfile
echo "password=$password" >> ~/ztvh/user/userfile
rm fakefile
else
rm fakefile
clear
exit 0
fi;;
2) dialog --backtitle "[L42W0] ZATTOO UNLIMITED BETA > LOGOUT" --title "LOGOUT" --infobox "Logging out..." 3 40
rm fakefile
cd ~/ztvh
rm channels.m3u favorites.m3u chpipe.sh zattoo_fullepg.xml zattoo_ext_fullepg.xml -rf user -rf work -rf epg -rf logos -rf chpipe 2> /dev/null
dialog --backtitle "[L42S0] ZATTOO UNLIMITED BETA > LOGOUT" --title "LOGOUT" --infobox "Logging out... DONE" 3 40
sleep 2s
clear
exit 0;;
esac
if [ -e fakefile ]
then
clear
exit 1
fi
elif grep -q '403 Forbidden' login.txt
then
sed "s/PROVIDER/$provider/g" ~/ztvh/save_page.js > ~/ztvh/work/save_page.js
if grep -q "insecure=true" ~/ztvh/user/userfile
then
dialog --backtitle "[L41C0] [INSECURE] ZATTOO UNLIMITED BETA > LOGIN" --title "LOGIN" --infobox "Login to webservice..." 3 40
if phantomjs -platform offscreen --ignore-ssl-errors=true ~/ztvh/work/save_page.js https://$provider/login > cookie_list | grep -q "This application failed to start"
then
if phantomjs --ignore-ssl-errors=true ~/ztvh/work/save_page.js https://$provider/login > cookie_list | grep -q "This application failed to start"
then
export QT_QPA_PLATFORM=phantom
if phantomjs -platform phantom --ignore-ssl-errors=true ~/ztvh/work/save_page.js https://$provider/login > cookie_list | grep -q "This application failed to start"
then
dialog --backtitle "[L41F0] [INSECURE] ZATTOO UNLIMITED BETA > LOGIN" --title "FATAL ERROR [1]" --infobox "PhantomJS failed to start!" 3 40
sleep 2s
exit 1
fi
fi
fi
else
dialog --backtitle "[L41C0] ZATTOO UNLIMITED BETA > LOGIN" --title "LOGIN" --infobox "Login to webservice..." 3 40
if phantomjs -platform offscreen ~/ztvh/work/save_page.js https://$provider/login > cookie_list | grep -q "This application failed to start"
then
if phantomjs ~/ztvh/work/save_page.js https://$provider/login > cookie_list | grep -q "This application failed to start"
then
export QT_QPA_PLATFORM=phantom
if phantomjs -platform phantom ~/ztvh/work/save_page.js https://$provider/login > cookie_list | grep -q "This application failed to start"
then
dialog --backtitle "[L41F0] ZATTOO UNLIMITED BETA > LOGIN" --title "FATAL ERROR [1]" --infobox "PhantomJS failed to start!" 3 40
sleep 2s
exit 1
fi
fi
fi
fi
rm fakefile 2> /dev/null
touch fakefile
until grep -q "beaker.session.id" cookie_list
do
if grep 'TRY' fakefile | wc -l | grep -q 3 2> /dev/null
then
if grep -q "insecure=true" ~/ztvh/user/userfile
then
dialog --backtitle "[L41F0] [INSECURE] ZATTOO UNLIMITED BETA > LOGIN" --title "[2] FATAL ERROR" --infobox "Service unavailable! Please try again later!" 5 50
else
dialog --backtitle "[L41F0] ZATTOO UNLIMITED BETA > LOGIN" --title "[2] FATAL ERROR" --infobox "Service unavailable! Please try again later!" 5 50
fi
sleep 2s
exit 1
fi
echo "TRY" >> fakefile
sleep 1s
if grep -q "insecure=true" ~/ztvh/user/userfile
then
dialog --backtitle "[L41D0] [INSECURE] ZATTOO UNLIMITED BETA > LOGIN" --infobox "Waiting for required cookie data." 3 50
else
dialog --backtitle "[L41D0] ZATTOO UNLIMITED BETA > LOGIN" --infobox "Waiting for required cookie data." 3 50
fi
sleep 1s
if grep -q "insecure=true" ~/ztvh/user/userfile
then
dialog --backtitle "[L41D0] [INSECURE] ZATTOO UNLIMITED BETA > LOGIN" --infobox "Waiting for required cookie data.." 3 50
else
dialog --backtitle "[L41D0] ZATTOO UNLIMITED BETA > LOGIN" --infobox "Waiting for required cookie data.." 3 50
fi
sleep 1s
if grep -q "insecure=true" ~/ztvh/user/userfile
then
dialog --backtitle "[L41D0] [INSECURE] ZATTOO UNLIMITED BETA > LOGIN" --infobox "Waiting for required cookie data..." 3 50
else
dialog --backtitle "[L41D0] ZATTOO UNLIMITED BETA > LOGIN" --infobox "Waiting for required cookie data..." 3 50
fi
if grep -q "insecure=true" ~/ztvh/user/userfile
then
if phantomjs -platform offscreen --ignore-ssl-errors=true ~/ztvh/work/save_page.js https://$provider/login > cookie_list | grep -q "This application failed to start"
then
if phantomjs --ignore-ssl-errors=true ~/ztvh/work/save_page.js https://$provider/login > cookie_list | grep -q "This application failed to start"
then
export QT_QPA_PLATFORM=phantom
if phantomjs -platform phantom --ignore-ssl-errors=true ~/ztvh/work/save_page.js https://$provider/login > cookie_list | grep -q "This application failed to start"
then
dialog --backtitle "[L41F0] [INSECURE] ZATTOO UNLIMITED BETA > LOGIN" --title "FATAL ERROR [3]" --infobox "PhantomJS failed to start!" 3 50
exit 1
fi
fi
fi
else
if phantomjs -platform offscreen ~/ztvh/work/save_page.js https://$provider/login > cookie_list | grep -q "This application failed to start"
then
if phantomjs ~/ztvh/work/save_page.js https://$provider/login > cookie_list | grep -q "This application failed to start"
then
export QT_QPA_PLATFORM=phantom
if phantomjs -platform phantom ~/ztvh/work/save_page.js https://$provider/login > cookie_list | grep -q "This application failed to start"
then
dialog --backtitle "[L41F0] ZATTOO UNLIMITED BETA > LOGIN" --title "FATAL ERROR [3]" --infobox "PhantomJS failed to start!" 3 50
sleep 2s
exit 1
fi
fi
fi
fi
done
grep "beaker.session.id" cookie_list > ~/ztvh/user/session
session=$(<~/ztvh/user/session)
elif curl -v --silent https://$provider/ 2>&1 | grep -q -E "server certificate verification failed|SSL certificate problem" 2> /dev/null
then
echo "insecure=ask" >> ~/ztvh/user/userfile
dialog --backtitle "[L41F0] ZATTOO UNLIMITED BETA > LOGIN" --title "[4] FATAL ERROR" --infobox "Server certificate verification failed!" 3 50
sleep 2s
exit 1
else
if grep -q "insecure=true" ~/ztvh/user/userfile
then
dialog --backtitle "[L41F0] [INSECURE] ZATTOO UNLIMITED BETA > LOGIN" --title "[5] FATAL ERROR" --infobox "Service unavailable! Please try again later!" 5 50
else
dialog --backtitle "[L41F0] ZATTOO UNLIMITED BETA > LOGIN" --title "[5] FATAL ERROR" --infobox "Service unavailable! Please try again later!" 5 50
fi
sleep 2s
exit 1
fi
else
mkdir ~/ztvh/user 2> /dev/null
#
# PROVIDER
#
# L1000 MENU OVERLAY
echo 'dialog --backtitle "[L1000] ZATTOO UNLIMITED BETA > PROVIDER" --title "PROVIDER" --menu "Please choose your IPTV provider based on Zattoo services:" 10 50 10 \' > menu
# L1100 ZATTOO.COM
echo ' 1 "ZATTOO | Zattoo Germany / Switzerland " \' >> menu
# L1200 RESELLER
echo ' 2 "RESELLER | 1&1 TV, EWE TV, NetCologne ..." \' >> menu
echo "2>value" >> menu
if grep -q "MENU" value 2> /dev/null
then
rm cookie_list ~/ztvh/user/userfile 2> /dev/null
bash menu
if test $? -eq 0
then
true
else
dialog --backtitle "[L1X00] ZATTOO UNLIMITED BETA" --title "EXIT" --yesno "Do you want to quit?" 5 30
response=$?
if [ $response = 1 ]
then
echo "MENU" > value
elif [ $response = 0 ]
then
clear
exit 0
else
echo "MENU" > value
fi
fi
fi
#
# L1100 PROVIDER CHECK
#
if grep -q -E "1|2" value 2> /dev/null
then
until grep -q "beaker.session.id" cookie_list 2> /dev/null
do
rm ~/ztvh/user/session 2> /dev/null
if grep -q "insecure=ask" ~/ztvh/user/userfile 2> /dev/null
then
dialog --backtitle "[L11A0] ZATTOO UNLIMITED BETA > PROVIDER" --title "WARNING" --yesno "Please note that the server certification verification failed.\nYou are able to connect to the IPTV web service, but the server can't be verified as secure due to a problem with the certificate.\n\nMore information: https://curl.haxx.se/docs/sslcerts.html\n\nDo you want to disable SSL verification?" 13 70
elif grep -q "1" value
then
echo "provider=zattoo.com" > ~/ztvh/user/userfile
provider=$(echo "zattoo.com")
else
provider=$(dialog --backtitle "[L1100] ZATTOO UNLIMITED BETA > PROVIDER" --title "PROVIDER" --inputbox "\nPlease enter the domain of your IPTV provider,\ne.g. '1und1.tv', 'tvonline.ewe.de' ..." 9 50 3>&1 1>&2 2>&3 3>&-)
fi
if test $? -eq 0
then
sed -i "s/insecure=ask/insecure=true/g" ~/ztvh/user/userfile 2> /dev/null
if echo "$provider" | grep -q "zattoo.com"
then
echo "1" > value
fi
until echo "$provider" | grep -q ".*[.][cdnt][cehov]"
do
sed -i '/provider/d' ~/ztvh/user/userfile
provider=$(dialog --backtitle "[L11E0] ZATTOO UNLIMITED BETA > PROVIDER" --title "PROVIDER" --inputbox "PROVIDER invalid! | Syntax: domain.xxx\nPlease enter the domain of your IPTV provider,\ne.g. '1und1.tv', 'tvonline.ewe.de' ..." 9 50 3>&1 1>&2 2>&3 3>&-)
if test $? -eq 0
then
sed -i "s/insecure=ask/insecure=true/g" ~/ztvh/user/userfile 2> /dev/null
if echo "$provider" | grep -q "zattoo.com"
then
echo "1" > value
fi
else
echo "MENU" > value
echo "beaker.session.id=dummy" > cookie_list
provider=$(echo "dummy.com")
fi
done
else
echo "beaker.session.id=dummy" > cookie_list
echo "MENU" > value
fi
if ! grep -q "beaker.session.id=dummy" cookie_list 2> /dev/null
then
if grep -q "insecure=true" ~/ztvh/user/userfile 2> /dev/null
then
dialog --backtitle "[L11W0] [INSECURE] ZATTOO UNLIMITED BETA > PROVIDER" --infobox "Checking availability of chosen provider..." 3 50
else
dialog --backtitle "[L11W0] ZATTOO UNLIMITED BETA > PROVIDER" --infobox "Checking availability of chosen provider..." 3 50
fi
if ! grep -q "insecure=true" ~/ztvh/user/userfile 2> /dev/null
then
echo "provider=$provider" > ~/ztvh/user/userfile
fi
sed "s/PROVIDER/$provider/g" ~/ztvh/save_page.js > ~/ztvh/work/save_page.js 2> /dev/null
if grep -q "insecure=true" ~/ztvh/user/userfile 2> /dev/null
then
if phantomjs -platform offscreen --ignore-ssl-errors=true ~/ztvh/work/save_page.js https://$provider/login > cookie_list | grep -q "This application failed to start"
then
if phantomjs --ignore-ssl-errors=true ~/ztvh/work/save_page.js https://$provider/login > cookie_list | grep -q "This application failed to start"
then
export QT_QPA_PLATFORM=phantom
if phantomjs -platform phantom --ignore-ssl-errors=true ~/ztvh/work/save_page.js https://$provider/login > cookie_list | grep -q "This application failed to start"
then
dialog --backtitle "[L11F0] [INSECURE] ZATTOO UNLIMITED BETA > PROVIDER" --title "[1] FATAL ERROR" --infobox "PhantomJS failed to start!" 3 50
sleep 2s
exit 1
fi
fi
fi
else
if phantomjs -platform offscreen ~/ztvh/work/save_page.js https://$provider/login > cookie_list | grep -q "This application failed to start"
then
if phantomjs ~/ztvh/work/save_page.js https://$provider/login > cookie_list | grep -q "This application failed to start"
then
export QT_QPA_PLATFORM=phantom
if phantomjs -platform phantom ~/ztvh/work/save_page.js https://$provider/login > cookie_list | grep -q "This application failed to start"
then
dialog --backtitle "[L11F0] ZATTOO UNLIMITED BETA > PROVIDER" --title "[1] FATAL ERROR" --infobox "PhantomJS failed to start!" 3 50
sleep 2s
exit 1
fi
fi
fi
fi
if ! grep -q "beaker.session.id" cookie_list
then
if grep -q "uuid" cookie_list
then
if grep -q "insecure=true" ~/ztvh/user/userfile
then
dialog --backtitle "[L11C0] [INSECURE] ZATTOO UNLIMITED BETA > PROVIDER" --infobox "Waiting for required cookie data" 3 50
else
dialog --backtitle "[L11C0] ZATTOO UNLIMITED BETA > PROVIDER" --infobox "Waiting for required cookie data" 3 50
fi
rm fakefile 2> /dev/null
touch fakefile
until grep -q "beaker.session.id" cookie_list
do
if grep 'TRY' fakefile | wc -l | grep -q 3 2> /dev/null
then
if grep -q "1" value
then
echo "beaker.session.id=dummy1" > cookie_list
echo "MENU" > value
else
echo "beaker.session.id=dummy2" > cookie_list
echo "2" > value
fi
elif grep -q "uuid" cookie_list
then
echo "TRY" >> fakefile
sleep 1s
if grep -q "insecure=true" ~/ztvh/user/userfile
then
dialog --backtitle "[L11C0] [INSECURE] ZATTOO UNLIMITED BETA > PROVIDER" --infobox "Waiting for required cookie data." 3 50
else
dialog --backtitle "[L11C0] ZATTOO UNLIMITED BETA > PROVIDER" --infobox "Waiting for required cookie data." 3 50
fi
sleep 1s
if grep -q "insecure=true" ~/ztvh/user/userfile
then
dialog --backtitle "[L11C0] [INSECURE] ZATTOO UNLIMITED BETA > PROVIDER" --infobox "Waiting for required cookie data.." 3 50
else
dialog --backtitle "[L11C0] ZATTOO UNLIMITED BETA > PROVIDER" --infobox "Waiting for required cookie data.." 3 50
fi
sleep 1s
if grep -q "insecure=true" ~/ztvh/user/userfile
then
dialog --backtitle "[L11C0] [INSECURE] ZATTOO UNLIMITED BETA > PROVIDER" --infobox "Waiting for required cookie data..." 3 50
else
dialog --backtitle "[L11C0] ZATTOO UNLIMITED BETA > PROVIDER" --infobox "Waiting for required cookie data..." 3 50
fi
if grep -q "insecure=true" ~/ztvh/user/userfile
then
if phantomjs -platform offscreen --ignore-ssl-errors=true ~/ztvh/work/save_page.js https://$provider/login > cookie_list | grep -q "This application failed to start"
then
if phantomjs --ignore-ssl-errors=true ~/ztvh/work/save_page.js https://$provider/login > cookie_list | grep -q "This application failed to start"
then
export QT_QPA_PLATFORM=phantom
if phantomjs -platform phantom --ignore-ssl-errors=true ~/ztvh/work/save_page.js https://$provider/login > cookie_list | grep -q "This application failed to start"
then
dialog --backtitle "[L11F0] [INSECURE] ZATTOO UNLIMITED BETA > PROVIDER" --title "[2] FATAL ERROR" --infobox "PhantomJS failed to start!" 3 50
sleep 2s
exit 1
fi
fi
fi
else
if phantomjs -platform offscreen ~/ztvh/work/save_page.js https://$provider/login > cookie_list | grep -q "This application failed to start"
then
if phantomjs ~/ztvh/work/save_page.js https://$provider/login > cookie_list 2> /dev/null | grep -q "This application failed to start"
then
export QT_QPA_PLATFORM=phantom
if phantomjs -platform phantom ~/ztvh/work/save_page.js https://$provider/login > cookie_list | grep -q "This application failed to start"
then
dialog --backtitle "[L11F0] ZATTOO UNLIMITED BETA > PROVIDER" --title "[2] FATAL ERROR" --infobox "PhantomJS failed to start!" 3 50
sleep 2s
exit 1
fi
fi
fi
fi
else
echo "beaker.session.id=dummy" > cookie_list
fi
done
if grep -q "beaker.session.id=dummy[1-2]" cookie_list
then
dialog --backtitle "[L11E0] ZATTOO UNLIMITED BETA > PROVIDER" --title "[1] ERROR" --msgbox "Failed to load Session ID!" 5 50
elif grep -q "beaker.session.id=dummy" cookie_list
then
sed -i "/beaker.session.id/d" cookie_list
else
rm fakefile 2> /dev/null
fi
elif ! grep -q "www." ~/ztvh/work/save_page.js
then
sed -i "s/https:\/\//&www./g" ~/ztvh/work/save_page.js
sed -i "s/provider=/&www./g" ~/ztvh/user/userfile
if grep -q "insecure=true" ~/ztvh/user/userfile
then
dialog --backtitle "[L11R0] [INSECURE] ZATTOO UNLIMITED BETA > PROVIDER" --infobox "Checking availability of chosen provider..." 3 50
if phantomjs -platform offscreen --ignore-ssl-errors=true ~/ztvh/work/save_page.js https://www.$provider/login > cookie_list | grep -q "This application failed to start"
then
if phantomjs --ignore-ssl-errors=true ~/ztvh/work/save_page.js https://www.$provider/login > cookie_list | grep -q "This application failed to start"
then
export QT_QPA_PLATFORM=phantom
if phantomjs -platform phantom --ignore-ssl-errors=true ~/ztvh/work/save_page.js https://www.$provider/login > cookie_list | grep -q "This application failed to start"
then
dialog --backtitle "[L11F0] [INSECURE] ZATTOO UNLIMITED BETA > PROVIDER" --title "[3] FATAL ERROR" --infobox "PhantomJS failed to start!" 3 50
sleep 2s
exit 1
fi
fi
fi
else
dialog --backtitle "[L11R0] ZATTOO UNLIMITED BETA > PROVIDER" --infobox "Checking availability of chosen provider..." 3 50
if phantomjs -platform offscreen ~/ztvh/work/save_page.js https://www.$provider/login > cookie_list | grep -q "This application failed to start"
then
if phantomjs ~/ztvh/work/save_page.js https://www.$provider/login > cookie_list | grep -q "This application failed to start"
then
export QT_QPA_PLATFORM=phantom
if phantomjs -platform phantom ~/ztvh/work/save_page.js https://www.$provider/login > cookie_list | grep -q "This application failed to start"
then
dialog --backtitle "[L11F0] ZATTOO UNLIMITED BETA > PROVIDER" --title "[3] FATAL ERROR" --infobox "PhantomJS failed to start!" 3 50
sleep 2s
exit 1
fi
fi
fi
fi
fi
fi
if ! grep -q "beaker.session.id" cookie_list
then
if grep -q "uuid" cookie_list
then
if grep -q "insecure=true" ~/ztvh/user/userfile
then
dialog --backtitle "[L11D0] [INSECURE] ZATTOO UNLIMITED BETA > PROVIDER" --infobox "Waiting for required cookie data" 3 50
else
dialog --backtitle "[L11D0] ZATTOO UNLIMITED BETA > PROVIDER" --infobox "Waiting for required cookie data" 3 50
fi
rm fakefile 2> /dev/null
touch fakefile
until grep -q "beaker.session.id" cookie_list
do
if grep 'TRY' fakefile | wc -l | grep -q 3 2> /dev/null
then
if grep -q "1" value
then
echo "beaker.session.id=dummy1" > cookie_list
echo "MENU" > value
else
echo "beaker.session.id=dummy2" > cookie_list
echo "2" > value
fi
elif grep -q "uuid" cookie_list
then
echo "TRY" >> fakefile
sleep 1s
if grep -q "insecure=true" ~/ztvh/user/userfile
then
dialog --backtitle "[L11D0] [INSECURE] ZATTOO UNLIMITED BETA > PROVIDER" --infobox "Waiting for required cookie data." 3 50
else
dialog --backtitle "[L11D0] ZATTOO UNLIMITED BETA > PROVIDER" --infobox "Waiting for required cookie data." 3 50
fi
sleep 1s
if grep -q "insecure=true" ~/ztvh/user/userfile
then
dialog --backtitle "[L11D0] [INSECURE] ZATTOO UNLIMITED BETA > PROVIDER" --infobox "Waiting for required cookie data.." 3 50
else
dialog --backtitle "[L11D0] ZATTOO UNLIMITED BETA > PROVIDER" --infobox "Waiting for required cookie data.." 3 50
fi
sleep 1s
if grep -q "insecure=true" ~/ztvh/user/userfile
then
dialog --backtitle "[L11D0] [INSECURE] ZATTOO UNLIMITED BETA > PROVIDER" --infobox "Waiting for required cookie data..." 3 50
else
dialog --backtitle "[L11D0] ZATTOO UNLIMITED BETA > PROVIDER" --infobox "Waiting for required cookie data..." 3 50
fi
if grep -q "insecure=true" ~/ztvh/user/userfile
then
if phantomjs -platform offscreen --ignore-ssl-errors=true ~/ztvh/work/save_page.js https://www.$provider/login > cookie_list | grep -q "This application failed to start"
then
if phantomjs --ignore-ssl-errors=true ~/ztvh/work/save_page.js https://www.$provider/login > cookie_list | grep -q "This application failed to start"
then
export QT_QPA_PLATFORM=phantom
if phantomjs -platform phantom --ignore-ssl-errors=true ~/ztvh/work/save_page.js https://www.$provider/login > cookie_list | grep -q "This application failed to start"
then
dialog --backtitle "[L11F0] [INSECURE] ZATTOO UNLIMITED BETA > PROVIDER" --title "[4] FATAL ERROR" --infobox "PhantomJS failed to start!" 3 50
sleep 2s
exit 1
fi
fi
fi
else
if phantomjs -platform offscreen ~/ztvh/work/save_page.js https://www.$provider/login > cookie_list | grep -q "This application failed to start"
then
if phantomjs ~/ztvh/work/save_page.js https://www.$provider/login > cookie_list | grep -q "This application failed to start"
then
export QT_QPA_PLATFORM=phantom
if phantomjs -platform phantom ~/ztvh/work/save_page.js https://www.$provider/login > cookie_list | grep -q "This application failed to start"
then
dialog --backtitle "[L11F0] ZATTOO UNLIMITED BETA > PROVIDER" --title "[4] FATAL ERROR" --infobox "PhantomJS failed to start!" 3 50
sleep 2s
exit 1
fi
fi
fi
fi
else
echo "beaker.session.id=dummy" > cookie_list
fi
done
if grep -q "beaker.session.id=dummy[1-2]" cookie_list
then
dialog --backtitle "[L11E0] ZATTOO UNLIMITED BETA > PROVIDER" --title "[2] ERROR" --msgbox "Failed to load Session ID!" 5 50
elif grep -q "beaker.session.id=dummy" cookie_list
then
sed -i "/beaker.session.id/d" cookie_list
else
rm fakefile 2> /dev/null
fi
elif echo "$provider" | grep -q "www."
then
if curl -v --silent https://$provider/ 2>&1 | grep -q -E "server certificate verification failed|SSL certificate problem" 2> /dev/null
then
dialog --backtitle "[L11E0] ZATTOO UNLIMITED BETA > PROVIDER" --title "[3] ERROR" --infobox "Server certificate verification failed!" 3 50
sleep 2s
echo "insecure=ask" >> ~/ztvh/user/userfile
if grep -q "1" value
then
echo "beaker.session.id=dummy" > cookie_list
echo "MENU" > value
else
echo "2" > value
fi
elif ! ping -q -w 1 -c 1 `ip r | grep default | cut -d ' ' -f 3` > /dev/null 2> /dev/null
then
dialog --backtitle "[L11F0] ZATTOO UNLIMITED BETA > PROVIDER" --title "[5] FATAL ERROR" --msgbox "Internet connection unavailable! Please retry later!" 5 60
exit 1
else
dialog --backtitle "[L11E0] ZATTOO UNLIMITED BETA > PROVIDER" --title "[4] ERROR" --msgbox "Service unavailable!" 5 50
if grep -q "1" value
then
echo "beaker.session.id=dummy" > cookie_list
echo "MENU" > value
else
echo "2" > value
fi
fi
elif echo "$(<~/ztvh/user/userfile)" | grep -q "www."
then
if curl -v --silent https://www.$provider/ 2>&1 | grep -q -E "server certificate verification failed|SSL certificate problem" 2> /dev/null
then
dialog --backtitle "[L11E0] ZATTOO UNLIMITED BETA > PROVIDER" --title "[5] ERROR" --infobox "Server certificate verification failed!" 3 50
sleep 2s
echo "insecure=ask" >> ~/ztvh/user/userfile
sed -i "s/www.//g" ~/ztvh/user/userfile
sed -i "s/www.//g" ~/ztvh/work/save_page.js
if grep -q "1" value
then
echo "beaker.session.id=dummy" > cookie_list
echo "MENU" > value
else
echo "2" > value
fi
elif ! ping -q -w 1 -c 1 `ip r | grep default | cut -d ' ' -f 3` > /dev/null 2> /dev/null
then
dialog --backtitle "[L11F0] ZATTOO UNLIMITED BETA > PROVIDER" --title "[6] FATAL ERROR" --msgbox "Internet connection unavailable! Please retry later!" 5 60
exit 1
else
dialog --backtitle "[L11E0] ZATTOO UNLIMITED BETA > PROVIDER" --title "[6] ERROR" --msgbox "Service unavailable!" 5 50
if grep -q "1" value
then
echo "beaker.session.id=dummy" > cookie_list
echo "MENU" > value
else
echo "2" > value
fi
fi
else
if curl -v --silent https://$provider/ 2>&1 | grep -q -E "server certificate verification failed|SSL certificate problem" 2> /dev/null
then
dialog --backtitle "[L11E0] ZATTOO UNLIMITED BETA > PROVIDER" --title "[7] ERROR" --infobox "Server certificate verification failed!" 3 50
sleep 2s
echo "insecure=ask" >> ~/ztvh/user/userfile
sed -i "s/www.//g" ~/ztvh/user/userfile
sed -i "s/www.//g" ~/ztvh/work/save_page.js
if grep -q "1" value
then
echo "beaker.session.id=dummy" > cookie_list
echo "MENU" > value
else
echo "2" > value
fi
elif ! ping -q -w 1 -c 1 `ip r | grep default | cut -d ' ' -f 3` > /dev/null 2> /dev/null
then
dialog --backtitle "[L11F0] ZATTOO UNLIMITED BETA > PROVIDER" --title "[7] FATAL ERROR" --msgbox "Internet connection unavailable! Please retry later!" 5 60
exit 1
else
dialog --backtitle "[L11E0] ZATTOO UNLIMITED BETA > PROVIDER" --title "[8] ERROR" --msgbox "Service unavailable!" 5 50
if grep -q "1" value
then
echo "beaker.session.id=dummy" > cookie_list
echo "MENU" > value
else
echo "2" > value
fi
fi
fi
fi
fi
if grep -q "beaker.session.id=dummy2" cookie_list 2> /dev/null
then
sed -i "/beaker.session.id/d" cookie_list 2> /dev/null
fi
done
grep "beaker.session.id" cookie_list > ~/ztvh/user/session
fi
#
# L2100 ZATTOO EMAIL ADDRESS
#
if grep -q "1" value 2> /dev/null
then
sed -i "s/provider=www.zattoo.com/provider=zattoo.com/g" ~/ztvh/user/userfile 2> /dev/null
sed -i "s/https:\/\/www.zattoo.com/https:\/\/zattoo.com/g" ~/ztvh/work/save_page.js 2> /dev/null
provider=$(echo "zattoo.com")
sed -i "/login=/d" ~/ztvh/user/userfile 2> /dev/null
until grep -q '[A-Za-z0-9]@.*[A-Za-z0-9].*[.][a-z][a-z]' ~/ztvh/user/userfile
do
sed -i '/login/d' ~/ztvh/user/userfile
if grep -q "insecure=true" ~/ztvh/user/userfile
then
login=$(dialog --backtitle "[L2100] [INSECURE] ZATTOO UNLIMITED BETA > LOGIN" --title "ZATTOO | LOGIN PAGE" --inputbox "\nPlease enter your email address:" 8 50 3>&1 1>&2 2>&3 3>&-)
else
login=$(dialog --backtitle "[L2100] ZATTOO UNLIMITED BETA > LOGIN" --title "ZATTOO | LOGIN PAGE" --inputbox "\nPlease enter your email address:" 8 50 3>&1 1>&2 2>&3 3>&-)
fi
if test $? -eq 0
then
echo "login=$login" >> ~/ztvh/user/userfile
echo "PASSI" > value