-
Notifications
You must be signed in to change notification settings - Fork 4
/
InetcomTV.py
63 lines (51 loc) · 1.97 KB
/
InetcomTV.py
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
# -*- coding: utf-8 -*-
import os, sys, json
root_dir = os.path.dirname(sys.argv[0])
sys.path.append(root_dir)
import utils
class Scraper:
def __init__(self):
self.source = 'InetcomTV'
self.plist = 'http://api4.inetcom.tv/channel/all'
self.link = f'ext:{self.source}:'
self.headers = {'User-Agent': 'Mozilla/5.0 (Linux; Android 13) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.5938.140 Mobile Safari/537.36',
'X-Client-Info': 'AndroidPhone 50327582',
'X-Client-Model': 'OnePlus A5010',
'X-Device': '4',
'Referer': 'http://iptv.inetcom.ru/phone_app_v2/index.html?platform=AndroidPhone&serial=50327582',
'X-Requested-With': 'tv.inetcom.phone2',
}
def getHeaders(self):
return self.headers
def Channels(self):
LL=[]
RET_STATUS = False
http = utils.getURL(self.plist, headers=self.headers)
L = json.loads(http)
for cnLine in L:
try:
ch_id = cnLine["id"]
title = cnLine["caption"]
logo = cnLine["logoUrl"]
ids = utils.title_to_crc32(title)
url = f"{self.link}http://{ch_id}"
LL.append((ids, title, self.source, url, logo))
except: pass
if LL:
# Loading a Tuple into a Database (source, Tuple)
utils.ch_inputs_DB(self.source, LL)
RET_STATUS = True
return RET_STATUS
def getLink(self, lnk):
chURL = ''
chID = lnk.replace('http://', '')
http = utils.getURL(self.plist, headers=self.headers)
L = json.loads(http)
for cnLine in L:
try:
ch_id = cnLine["id"]
if int(ch_id) == int(chID):
chURL = cnLine["streams"]["hls"]
break
except: pass
return chURL