-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathexec.py
More file actions
75 lines (62 loc) · 2.53 KB
/
Copy pathexec.py
File metadata and controls
75 lines (62 loc) · 2.53 KB
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
# -*- coding: utf-8 -*-
import os
import xbmc
import urllib
import xbmcgui
from resources.lib.utils import *
from resources.lib.playlist import *
#append_pydev_remote_debugger
# if os.environ.get('TVBGPVRDEBUG'):
# sys.path.append(os.environ['PYSRC'])
# import pydevd
# pydevd.settrace('127.0.0.1', stdoutToServer=False, stderrToServer=False)
#end_append_pydev_remote_debugger
log("Addon running on: %s" % user_agent)
if scheduled_run:
log(translate(32004))
### If addon is started manually or is in debug mode, display the progress bar
if not scheduled_run or settings.debug:
progress_bar = xbmcgui.DialogProgressBG()
progress_bar.create(heading=this.getAddonInfo('name'))
try:
# Initialize the playlsit object
pl = Playlist(location=get_location(),
user_agent=user_agent,
progress=progress_bar,
temp_folder=profile_dir,
disabled_groups=get_disabled_groups(),
mapping_file=mapping_file)
if pl.count() == 0:
notify_error(translate(32000))
else:
### If there is a preferred quality for channels with multi streams,
### remove all unpreferred streams
if (settings.preferred_quality != ALL):
pl.set_preferred_quality(settings.preferred_quality)
### Reorder playlist as per the order in the template file
pl.reorder(template_file=get_template_file())
### Replace stream URLs with static ones
pl.set_static_stream_urls(STREAM_URL)
### Export channel names from original playlist
if settings.export_names:
names_file_path = os.path.join(settings.export_to_folder, "names.txt")
pl.save(path=names_file_path, type=PlaylistType.NAMES)
# Export channel names & ids from original playlist
# Needed only for the EPG generation. Users can disable it!!!
names_file_path = os.path.join(settings.export_to_folder, "channels.json")
pl.save(path=names_file_path, type=PlaylistType.JSON)
### Write playlist to disk
if not pl.save(path=pl_path):
notify_error(translate(32001))
### Copy playlist to additional folder if specified
if settings.copy_playlist and os.path.isdir(settings.copy_to_folder):
pl.save(path=os.path.join(settings.copy_to_folder, pl_name))
except Exception, er:
log(er, xbmc.LOGERROR)
### Schedule next run
interval = int(settings.run_on_interval) * 60
log(translate(32007) % interval)
command = "AlarmClock('ScheduledReload', %s, %s, silent)" % (RUNSCRIPT, interval)
xbmc.executebuiltin(command)
if progress_bar:
progress_bar.close()