forked from kodi1/service.subtitles.unacs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
common.py
49 lines (41 loc) · 1.06 KB
/
common.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
# -*- coding: utf-8 -*-
import sys
import os
from bs4 import BeautifulSoup
from bs4 import SoupStrainer
try:
import xbmc
run_from_xbmc = True
except ImportError:
run_from_xbmc = False
pass
if run_from_xbmc == True:
import xbmcvfs
import xbmcaddon
import xbmcgui
import xbmcplugin
list_key = ['rating', 'fps', 'url', 'cds', 'info', 'id']
path =''
def log_my(*msg):
if run_from_xbmc == True:
xbmc.log((u"### SSS-> %s" % (msg,)).encode('utf-8'),level=xbmc.LOGNOTICE)
#xbmc.log((u"### SSS-> %s" % (msg,)).encode('utf-8'),level=xbmc.LOGERROR)
else:
for m in msg:
print m,
print
def get_info(it):
str = 'Fps:{0} Cd:{1} - {2}'.format(it['fps'], it['cds'], it['info'])
return str
def savetofile(d, name):
if run_from_xbmc == False:
n = os.path.join(path, name)
f = open(n, 'wb')
f.write(d)
f.close
def dump_src(s, name):
if run_from_xbmc == False:
n = os.path.join(path, name)
f = open(n,'wb')
f.write(s.prettify().encode('utf-8', 'replace'))
f.close()