def wait_for_nzf(folder, sab_nzo_id, nzf): log("wait_for_nzf: folder: %s sab_nzo_id: %s nzf.filename: %s" % (folder, sab_nzo_id, nzf.filename)) iscanceled = False is_rar_found = False # If rar exist we skip dialogs some_rar = os.path.join(folder, nzf.filename) if utils.exists(some_rar): is_rar_found = True if not is_rar_found: progressDialog = xbmcgui.DialogProgress() progressDialog.create('Pneumatic', 'Request to SABnzbd succeeded, waiting for ', utils.short_string(nzf.filename)) time_now = time.time() while not is_rar_found: time.sleep(1) if utils.exists(some_rar): # TODO Look for optimization # Wait until the file is written to disk before proceeding size_now = float(nzf.bytes) size_later = 0 while (size_now != size_later) or (size_now == 0) or (size_later == 0): size_now = utils.size(some_rar) if size_now != size_later: time.sleep(0.5) size_later = utils.size(some_rar) is_rar_found = True break nzo = Nzo(sab_nzo_id) m_nzf = nzo.get_nzf_id(nzf.nzf_id) percent, label = utils.wait_for_rar_label(nzo, m_nzf, time_now) progressDialog.update(percent, 'Request to SABnzbd succeeded, waiting for', utils.short_string(nzf.filename), label) if progressDialog.iscanceled(): progressDialog.close() dialog = xbmcgui.Dialog() ret = dialog.select('What do you want to do?', ['Delete job', 'Just download']) # Fix for hang when playing .strm xbmc.Player().stop() xbmc.executebuiltin('Dialog.Close(all, true)') if ret == 0: sabnzbd.nzo_pause(sab_nzo_id) time.sleep(3) delete_ = sabnzbd.nzo_delete_files(sab_nzo_id) if not "ok" in delete_: xbmc.log(delete_) utils.notification("Deleting failed") else: utils.notification("Deleting succeeded") elif ret == 1: # allow the previous select dialog to close time.sleep(1) just_download({'nzoid': sab_nzo_id}) return True progressDialog.close() return iscanceled
def set_streaming(sab_nzo_id): # Set the post process to 0 = skip will cause SABnzbd to fail the job. requires streaming_allowed = 1 in sabnzbd.ini (6.x) setstreaming = SABNZBD.setStreaming('', sab_nzo_id) log("set_streaming: sab_nzo_id: %s msg %s" % (sab_nzo_id, setstreaming)) if not "ok" in setstreaming: utils.notification('Post process request to SABnzbd failed!') time.sleep(1) return
def add(cat, startDate, endDate, recordname): conn = getConnection() c = conn.cursor() c.execute("INSERT OR REPLACE INTO recordings(cat, name, start, end) VALUES(?, ?, ?, ?)", [cat, recordname, startDate, endDate]) conn.commit() c.close() if schedule(cat, startDate, endDate, recordname): utils.notification('Recording set for %s' % recordname)
def add(cat, startDate, endDate, recordname): conn = getConnection() c = conn.cursor() c.execute("INSERT OR REPLACE INTO recordings(cat, name, start, end) VALUES(?, ?, ?, ?)", [cat, recordname, startDate, endDate]) conn.commit() c.close() if schedule(cat, startDate, endDate, recordname): utils.notification('Recording set for %s' % recordname)
def createFollowingGameList(): username = utils.getUserName() if not username: utils.notification(PLUGIN.get_string(30095)) else: games = TWITCHTV.getFollowingGames(username) items = [CONVERTER.convertGameToListItem(element) for element in games] PLUGIN.set_content(utils.getContentType()) return items
def createFollowingGameList(): username = utils.getUserName() if not username: utils.notification(PLUGIN.get_string(30095)) else: games = TWITCHTV.getFollowingGames(username) items = [CONVERTER.convertGameToListItem(element) for element in games] PLUGIN.set_content(utils.getContentType()) return items
def title_changed(self, view, frame, title): windowtitle = self.window.get_title() if not title.startswith(const.INIIAL_TITLE) and not utils.same_title(windowtitle, title): self.tray.set_blinking(True) self.blinking = True utils.notification("有新消息来了", title) if title.startswith(const.INIIAL_TITLE): self.tray.set_blinking(False) self.blinking = False self.window.set_title(title)
def title_changed(self, view, frame, title): windowtitle = self.window.get_title() if not title.startswith(const.INIIAL_TITLE) and not utils.same_title(windowtitle, title): utils.notification("有新消息来了", title) self.iconChange('QQ1.png') self.blinking = True if title.startswith(const.INIIAL_TITLE): self.iconChange('QQ.png') self.blinking = False self.window.set_title(title)
def set_streaming(sab_nzo_id): # Set the post process to 0 = skip will cause SABnzbd to fail the job. requires streaming_allowed = 1 in sabnzbd.ini (6.x) setstreaming = "ok" pp_message = sabnzbd.nzo_pp(sab_nzo_id, 0) switch_message = sabnzbd.nzo_switch(sab_nzo_id, 0) log("set_streaming: sab_nzo_id: %s pp_message %s switch_message %s" % (sab_nzo_id, pp_message, switch_message)) if (not "ok" in pp_message) and (not "0" in switch_message): utils.notification('Post process request to SABnzbd failed!') time.sleep(1) setstreaming = "notOk" return setstreaming
def just_download(params): log("just_download: params: %s" % params) get = params.get sab_nzo_id = get("nzoid") category = get_category() set_category = sabnzbd.nzo_change_category(sab_nzo_id, category) log("just_download: set_category: %s" % set_category) if "ok" in set_category: utils.notification("Downloading") else: utils.notification("Manual repair required")
def set_streaming(sab_nzo_id): # Set the post process to 0 = skip will cause SABnzbd to fail the job. requires streaming_allowed = 1 in sabnzbd.ini (6.x) setstreaming = "ok" pp_message = sabnzbd.nzo_pp(sab_nzo_id, 0) switch_message = sabnzbd.nzo_switch(sab_nzo_id, 0) log("set_streaming: sab_nzo_id: %s pp_message %s switch_message %s" % (sab_nzo_id, pp_message, switch_message)) if (not "ok" in pp_message) and (not "0" in switch_message): utils.notification('Post process request to SABnzbd failed!') time.sleep(1) setstreaming = "notOk" return setstreaming
def just_download(params): log("just_download: params: %s" % params) get = params.get sab_nzo_id = get("nzoid") category = get_category() set_category = SABNZBD.set_category(id=sab_nzo_id, category=category) log("just_download: set_category: %s" % set_category) if "ok" in set_category: utils.notification("Downloading") else: utils.notification("Manual repair required")
def wait_for_nzf(folder, sab_nzo_id, nzf): log("wait_for_nzf: folder: %s sab_nzo_id: %s nzf.filename: %s" % (folder, sab_nzo_id, nzf.filename)) iscanceled = False is_rar_found = False # If rar exist we skip dialogs some_rar = os.path.join(folder, nzf.filename) if utils.exists(some_rar): is_rar_found = True if not is_rar_found: progressDialog = xbmcgui.DialogProgress() progressDialog.create('Pneumatic', 'Request to SABnzbd succeeded, waiting for ', utils.short_string(nzf.filename)) time_now = time.time() while not is_rar_found: time.sleep(1) if utils.exists(some_rar): # TODO Look for optimization # Wait until the file is written to disk before proceeding size_now = int(nzf.bytes) size_later = 0 while (size_now != size_later) or (size_now == 0) or (size_later == 0): size_now = utils.size(some_rar) if size_now != size_later: time.sleep(0.5) size_later = utils.size(some_rar) is_rar_found = True break nzo = sabnzbd.Nzo(SABNZBD, sab_nzo_id) m_nzf = nzo.get_nzf_id(nzf.nzf_id) percent, label = utils.wait_for_rar_label(nzo, m_nzf, time_now) progressDialog.update(percent, 'Request to SABnzbd succeeded, waiting for', utils.short_string(nzf.filename), label) if progressDialog.iscanceled(): progressDialog.close() dialog = xbmcgui.Dialog() ret = dialog.select('What do you want to do?', ['Delete job', 'Just download']) # Fix for hang when playing .strm xbmc.Player().stop() xbmc.executebuiltin('Dialog.Close(all, true)') if ret == 0: pause = SABNZBD.pause_queue(id=sab_nzo_id) time.sleep(3) delete_ = SABNZBD.delete_queue('',sab_nzo_id) if not "ok" in delete_: xbmc.log(delete_) utils.notification("Deleting failed") else: utils.notification("Deleting succeeded") elif ret == 1: # allow the previous select dialog to close time.sleep(1) just_download({'nzoid': sab_nzo_id}) return True progressDialog.close() return iscanceled
def repair(params): log("repair: params: %s" % params) get = params.get sab_nzo_id_history = get("nzoidhistory") end = get("end") repair_ = sabnzbd.nzo_retry(sab_nzo_id_history) log("repair: repair_: %s" % repair_) if "ok" in repair_: utils.notification("Repair succeeded") else: utils.notification("Repair failed") if not end: xbmc.executebuiltin("Action(ParentDir)") return
def btnsave_clicked(self, widget): self.config.login_password = self.txtPassword.get_text() self.config.proxy_uri = self.txtProxyUri.get_text() self.config.save_path = self.dcbtnSavePath.get_current_folder() try: keybinder.unbind(self.config.hot_key) except: pass self.config.hot_key = self.txtHotkey.get_text() keybinder.bind(self.config.hot_key, self.tray.keybind_callback) self.webview.init_proxy() self.config.save() utils.notification('保存配置成功', '部分配置重启程序后生效') self.window.destroy()
def repair(params): log("repair: params: %s" % params) get = params.get sab_nzo_id_history = get("nzoidhistory") end = get("end") repair_ = SABNZBD.repair('',sab_nzo_id_history) log("repair: repair_: %s" % repair_) if "ok" in repair_: utils.notification("Repair succeeded") else: utils.notification("Repair failed") if not end: xbmc.executebuiltin("Action(ParentDir)") return
def btnsave_clicked(self, widget): self.config.login_password = self.txtPassword.get_text() self.config.proxy_uri = self.txtProxyUri.get_text() self.config.save_path = self.dcbtnSavePath.get_current_folder() try: keybinder.unbind(self.config.hot_key) except: pass self.config.hot_key = self.txtHotkey.get_text() keybinder.bind(self.config.hot_key, self.tray.keybind_callback) self.webview.init_proxy() self.config.save() utils.notification('保存配置成功', '部分配置重启程序后生效') self.window.destroy()
def createFollowingList(): username = utils.getUserName() if not username: utils.notification(PLUGIN.get_string(30095)) else: streams = TWITCHTV.getFollowingStreams(username) liveStreams = [CONVERTER.convertStreamToListItem(stream) for stream in streams[Keys.LIVE]] liveStreams.insert(0, {'path': PLUGIN.url_for(endpoint='createFollowingList'), 'icon': Images.ICON, 'thumbnail': Images.THUMB, 'art': utils.theArt(), 'is_playable': False, 'label': PLUGIN.get_string(30012)}) liveStreams.append({'path': PLUGIN.url_for(endpoint='createFollowingList'), 'icon': Images.ICON, 'thumbnail': Images.THUMB, 'art': utils.theArt(), 'is_playable': False, 'label': PLUGIN.get_string(30013)}) liveStreams.extend([CONVERTER.convertFollowersToListItem(follower) for follower in streams[Keys.OTHERS]]) utils.refreshPreviews() PLUGIN.set_content(utils.getContentType()) return liveStreams
def createFollowingList(): username = utils.getUserName() if not username: utils.notification(PLUGIN.get_string(30095)) else: streams = TWITCHTV.getFollowingStreams(username) liveStreams = [CONVERTER.convertStreamToListItem(stream) for stream in streams[Keys.LIVE]] liveStreams.insert(0, {'path': PLUGIN.url_for(endpoint='createFollowingList'), 'icon': Images.ICON, 'thumbnail': Images.THUMB, 'art': utils.theArt(), 'is_playable': False, 'label': PLUGIN.get_string(30012)}) liveStreams.append({'path': PLUGIN.url_for(endpoint='createFollowingList'), 'icon': Images.ICON, 'thumbnail': Images.THUMB, 'art': utils.theArt(), 'is_playable': False, 'label': PLUGIN.get_string(30013)}) liveStreams.extend([CONVERTER.convertFollowersToListItem(follower) for follower in streams[Keys.OTHERS]]) utils.refreshPreviews() PLUGIN.set_content(utils.getContentType()) return liveStreams
def delete(params): log("delete: params: %s" % params) get = params.get sab_nzo_id = get("nzoid") sab_nzo_id_history = get("nzoidhistory") sab_nzo_id_history_list = get("nzoidhistory_list") if sab_nzo_id_history_list: sab_nzo_id_history_list = utils.unquote_plus( sab_nzo_id_history_list).split(";") folder = get("folder") folder = utils.unquote_plus(folder) incomplete = get("incomplete") end = get("end") delete_all = get("delete_all") if delete_all: utils.notification("Deleting all incomplete") else: utils.notification("Deleting %s" % xbmc.translatePath(folder)) if sab_nzo_id or sab_nzo_id_history: delete_ = "ok" if sab_nzo_id: if not "None" in sab_nzo_id and not delete_all: pause = sabnzbd.nzo_pause(sab_nzo_id) log("delete: pause: %s" % pause) time.sleep(3) if "ok" in pause: delete_ = sabnzbd.nzo_delete_files(sab_nzo_id) log("delete: delete_: %s" % delete_) else: delete_ = "failed" if sab_nzo_id_history: if not "None" in sab_nzo_id_history and not delete_all: delete_ = sabnzbd.nzo_delete_history_files(sab_nzo_id_history) if delete_all and sab_nzo_id_history_list: for sab_nzo_id_history_item in sab_nzo_id_history_list: delete_state = sabnzbd.nzo_delete_history_files( sab_nzo_id_history_item) if delete_state is not delete_: delete_state = "failed" delete_ = delete_state if not "ok" in delete_: utils.notification("Deleting failed") else: utils.notification("Deleting failed") log("delete: deleting failed") if end: return elif incomplete: time.sleep(2) xbmc.executebuiltin("Container.Refresh") else: xbmc.executebuiltin("Action(ParentDir)") return
def handle_demo_mode(monitor, player, state, now_playing_item, called=[False]): # pylint: disable=dangerous-default-value if not state.demo_mode or called[0]: called[0] = False return utils.notification('UpNext demo mode', 'Active') log('Active') # Force use of addon data method if demo plugin mode is enabled if state.get_addon_type() is None and state.demo_plugin: addon_id = utils.get_addon_id() upnext_info = plugin.generate_data(now_playing_item, addon_id, state) if upnext_info: log('Plugin data sent') called[0] = True upnext.send_signal(addon_id, upnext_info) # Seek to 15s before end of video if state.demo_seek == constants.DEMO_SEEK_15S: seek_time = player.getTotalTime() - 15 # Seek to popup start time elif state.demo_seek == constants.DEMO_SEEK_POPUP_TIME: seek_time = state.get_popup_time() # Seek to detector start time elif state.demo_seek == constants.DEMO_SEEK_DETECT_TIME: seek_time = state.get_detect_time() else: return with player as check_fail: log('Seeking to end') player.seekTime(seek_time) # Seek workaround required for AML HW decoder on certain problematic # H.265 encodes to avoid buffer desync and playback hangs monitor.waitForAbort(3) if player.getTime() <= seek_time: log('Seek workaround') player.seekTime(seek_time + 3) check_fail = False if check_fail: log('Error: demo seek, nothing playing', utils.LOGWARNING)
def delete(params): log("delete: params: %s" % params) get = params.get sab_nzo_id = get("nzoid") sab_nzo_id_history = get("nzoidhistory") sab_nzo_id_history_list = get("nzoidhistory_list") if sab_nzo_id_history_list: sab_nzo_id_history_list = utils.unquote_plus(sab_nzo_id_history_list).split(";") folder = get("folder") folder = utils.unquote_plus(folder) incomplete = get("incomplete") end = get("end") delete_all = get("delete_all") if delete_all: utils.notification("Deleting all incomplete") else: utils.notification("Deleting %s" % xbmc.translatePath(folder)) if sab_nzo_id or sab_nzo_id_history: delete_ = "ok" if sab_nzo_id: if not "None" in sab_nzo_id and not delete_all: pause = SABNZBD.pause_queue(id=sab_nzo_id) log("delete: pause: %s" % pause) time.sleep(3) if "ok" in pause: delete_ = SABNZBD.delete_queue('',sab_nzo_id) log("delete: delete_: %s" % delete_) else: delete_ = "failed" if sab_nzo_id_history: if not "None" in sab_nzo_id_history and not delete_all: delete_ = SABNZBD.delete_history('',sab_nzo_id_history) if delete_all and sab_nzo_id_history_list: for sab_nzo_id_history_item in sab_nzo_id_history_list: delete_state = SABNZBD.delete_history('',sab_nzo_id_history_item) if delete_state is not delete_: delete_state = "failed" delete_ = delete_state if not "ok" in delete_: utils.notification("Deleting failed") else: utils.notification("Deleting failed") log("delete: deleting failed") if end: return elif incomplete: time.sleep(2) xbmc.executebuiltin("Container.Refresh") else: xbmc.executebuiltin("Action(ParentDir)") return
def download_status(self, download, pspec): if download.get_status() == -1: utils.notification("文件下载失败", self.config.save_path + '/' + download.get_suggested_filename()) if download.get_status() == 1: utils.notification("文件开始下载", self.config.save_path + '/' + download.get_suggested_filename()) if download.get_status() == 3: utils.notification("文件下载完成", self.config.save_path + '/' + download.get_suggested_filename())
def forbidden(message): """ helper function for check_* decorators. """ if not request.user.is_staff: # Standard users can't do anything except some rare # modifications on their own account. But they can # reach the current decorator because they have access # to 'users.views.mod()' in that case. If they are # trying to do something prohibited, someone should be # told, because they can't do it without forging URLs, # thus the action is voluntary and possibly evil. logging.warning(_(u'{0}: user {1} tried to alter ' u'account {2} with WMI action {3}!').format( stylize(ST_BAD, _('POSSIBLE BREAKIN ATTEMPT')), stylize(ST_LOGIN, wmi_user.login), stylize(ST_LOGIN, victim_user.login), stylize(ST_BAD, '%s(args=%s, kwargs=%s)' % (meta_action, args, kwargs)) ) ) utils.notification(request, message) return HttpResponseForbidden(message)
def RecursiveRecordingsPlanned(SearchAllFavorites): #import recordings cat = ADDON.getSetting('SearchRecursiveIn') if locking.isAnyRecordLocked(): locking.scanUnlockAll() return elif locking.isAnyScanLocked(): return else: locking.scanLock(SearchAllFavorites) if not locking.isScanLocked(SearchAllFavorites): return utils.log('findrecursivetvguide.py RUNNING RecursiveRecordingsPlanned','cat= %s, SearchAllFavorites= %s' % (repr(cat), repr(SearchAllFavorites))) ADDON.setSetting('RecursiveSearch','true') conn = recordings.getConnection() c = conn.cursor() c.execute("SELECT DISTINCT cat, name, start, end, alarmname, description, playchannel FROM recordings_adc WHERE name LIKE '%Recursive:%' COLLATE NOCASE") # Find all recursive recordings recordingsE = c.fetchall() # Put recursive recordings changed last - first recordingsC = sorted(recordingsE, key=itemgetter(2), reverse=True) utils.log('findrecursivetvguide.py: Recursive recordings',repr(recordingsC)) for index in range(0, len(recordingsC)): if isinstance(recordings.parseDate(recordingsC[index][2]), datetime.date) and isinstance(recordings.parseDate(recordingsC[index][3]), datetime.date) and 'Recursive:' in recordingsC[index][1]: if int(ADDON.getSetting('SearchRecursiveIn')) > 0 or ((not SearchAllFavorites == 'NotAllFavorites')and(not SearchAllFavorites == 'Once')and(not SearchAllFavorites == 'Hour')): if not recordingsC[index][0] in uniques: findrecursiveinplaychannel(recordingsC[index][0],recordingsC[index][1],index) # Allways search channel in record if ADDON.getSetting('NotifyOnSearch')=='true' and not '[COLOR orange]' in recordingsC[index][1]: utils.notification('Find%s [COLOR green]complete in own channel[/COLOR]' % recordingsC[index][1]) for cat in uniques: findrecursiveinplaychannel(cat,recordingsC[index][1],index) if ADDON.getSetting('NotifyOnSearch')=='true' and not '[COLOR orange]' in recordingsC[index][1]: utils.notification('Find%s [COLOR green]complete[/COLOR]' % recordingsC[index][1]) else: findrecursiveinplaychannel(recordingsC[index][0],recordingsC[index][1],index) if ADDON.getSetting('NotifyOnSearch')=='true' and not '[COLOR orange]' in recordingsC[index][1]: utils.notification('Find%s [COLOR green]complete[/COLOR] in selected channel: %s' % (recordingsC[index][1], recordingsC[index][0])) conn.commit() c.close() if ADDON.getSetting('NotifyOnSearch')=='true': utils.notification('Find all recursives [COLOR green]complete[/COLOR]') locking.scanUnlockAll() ADDON.setSetting('RecursiveSearch','false') return
def download_status(self, download, pspec): if download.get_status() == -1: utils.notification( "文件下载失败", self.config.save_path + '/' + download.get_suggested_filename()) if download.get_status() == 1: utils.notification( "文件开始下载", self.config.save_path + '/' + download.get_suggested_filename()) if download.get_status() == 3: utils.notification( "文件下载完成", self.config.save_path + '/' + download.get_suggested_filename())
def notification(label): utils.notification(label, __settings__.getAddonInfo("icon"))
def pre_play(nzbname, **kwargs): log("pre_play: nzbname: %s kwargs: %s" % (nzbname, kwargs)) mode = kwargs.get('mode', None) sab_nzo_id = kwargs.get('nzo', None) iscanceled = False folder = utils.join(INCOMPLETE_FOLDER, nzbname) folder_one = folder + '.1' if utils.exists(folder_one): folder = folder_one sab_file_list = [] multi_arch_list = [] if sab_nzo_id is None: sab_nzo_id_history = SABNZBD.nzo_id_history(nzbname) nzf_list = utils.dir_to_nzf_list(folder, sabnzbd) else: nzo = sabnzbd.Nzo(SABNZBD, sab_nzo_id) nzf_list = nzo.nzf_list() sab_nzo_id_history = None sorted_rar_nzf_list = utils.sorted_rar_nzf_file_list(nzf_list) # TODO # If we cant find any rars in the queue, we have to wait for SAB # and then guess the names... # if len(nzf_list) == 0: # iscanceled = get_nzf(folder, sab_nzo_id, None) is_movie_in_rar = True if len(sorted_rar_nzf_list) == 0: # look for other playable files multi_nzf_list = sorted_nzf_list = utils.sorted_movie_nzf_file_list(nzf_list) if len(multi_nzf_list) > 0: is_movie_in_rar = False else: multi_nzf_list = utils.sorted_multi_arch_nzf_list(sorted_rar_nzf_list) sorted_nzf_list = sorted_rar_nzf_list clean_sorted_nzf_list = utils.nzf_diff_list(sorted_nzf_list, multi_nzf_list) if len(multi_nzf_list) > 0: # Loop though all multi archives and add file to the play_list = [] for nzf in multi_nzf_list: if sab_nzo_id is not None: response = set_streaming(sab_nzo_id) log("pre_play: set_streaming: %s" % response) t = Thread(target=nzf_to_bottom, args=(sab_nzo_id, nzf_list, sorted_nzf_list,)) t.start() iscanceled = get_nzf(folder, sab_nzo_id, nzf) if iscanceled: break else: if is_movie_in_rar: # RAR ANALYSYS # in_rar_file_list = utils.rar_filenames(folder, nzf.filename) movie_list = utils.sort_filename(in_rar_file_list) log("pre_play: folder: %s nzf.filename: %s in_rar_file_list: %s" % (folder, nzf.filename, in_rar_file_list)) else: movie_list = [os.path.join(folder, nzf.filename)] # Make sure we have a movie if not (len(movie_list) >= 1): utils.notification("Not a movie!") log("pre_play: no movie in movie_list") break # Who needs sample? movie_no_sample_list = utils.no_sample_list(movie_list) # If auto play is enabled we skip samples in the play_list if AUTO_PLAY and mode is not MODE_INCOMPLETE_LIST: for movie_file in movie_no_sample_list: play_list.append(nzf.filename) play_list.append(movie_file) else: for movie_file in movie_list: play_list.append(nzf.filename) play_list.append(movie_file) # If the movie is a .mkv or .mp4 we need the last rar if utils.is_movie_mkv(movie_list) and sab_nzo_id and is_movie_in_rar: # If we have a sample or other file, the second rar is also needed.. if len(in_rar_file_list) > 1: second_nzf = clean_sorted_nzf_list[1] iscanceled = get_nzf(folder, sab_nzo_id, second_nzf) last_nzf = clean_sorted_nzf_list[-1] iscanceled = get_nzf(folder, sab_nzo_id, last_nzf) if iscanceled: break if iscanceled: log("pre_play: get_nzf: canceled") return else: rar_file_list = [x.filename for x in sorted_nzf_list] if (len(rar_file_list) >= 1) or (not is_movie_in_rar and len(movie_list) >= 1): if AUTO_PLAY and ( mode is None or mode is MODE_STRM): video_params = dict() if not mode: video_params['mode'] = MODE_AUTO_PLAY else: video_params['mode'] = MODE_STRM video_params['play_list'] = utils.quote_plus(';'.join(play_list)) video_params['file_list'] = utils.quote_plus(';'.join(rar_file_list)) video_params['folder'] = utils.quote_plus(folder) return play_video(video_params) else: return playlist_item(play_list, rar_file_list, folder, sab_nzo_id, sab_nzo_id_history) else: utils.notification("No rar\'s in the NZB!") log("pre_play: no rar\'s in the NZB") return else: utils.notification("No playable files found!") log("pre_play: no playable files found") return
def is_nzb_home(params): log("is_nzb_home: params: %s" % params) get = params.get nzb = utils.unquote_plus(get("nzb")) nzbname = m_nzb.Nzbname(utils.unquote_plus(get("nzbname"))).final_name folder = utils.join(INCOMPLETE_FOLDER, nzbname) iscanceled = False type = get('type', 'addurl') sab_nzo_id = SABNZBD.nzo_id(nzbname, nzb) log("is_nzb_home: folder: %s sab_nzo_id: %s" %(folder, sab_nzo_id)) if not utils.dir_exists(folder, sab_nzo_id): progressDialog = xbmcgui.DialogProgress() progressDialog.create('Pneumatic', 'Sending request to SABnzbd') category = get_category() if type == 'addurl': type, nzb = nzb_cache(type, nzb, nzbname) # SABnzbd and URI should be latin-1 encoded if type == 'addurl': response = SABNZBD.addurl(nzb.encode('latin-1'), nzbname, category=category) elif type == 'add_local': response = SABNZBD.add_local(nzb.encode('latin-1'), category=category) elif type == 'add_file': response = SABNZBD.add_file(nzb.encode('latin-1'), category=category) log("is_nzb_home: type: %s response: %s" %(type, response)) if "ok" in response: progressDialog.update(0, 'Request to SABnzbd succeeded', 'waiting for nzb download') seconds = 0 #SABnzbd uses nzb url as name until it has downloaded the nzb file sab_nzo_id_init = SABNZBD.nzo_id(nzbname, nzb) log("is_nzb_home: sab_nzo_id_init: %s" % sab_nzo_id_init) while not (sab_nzo_id and utils.exists(folder)): sab_nzo_id = SABNZBD.nzo_id(nzbname) label = str(seconds) + " seconds" log("is_nzb_home: waiting for nzb: sab_nzo_id: %s for: %s" % (sab_nzo_id, label)) progressDialog.update(0, 'Request to SABnzbd succeeded', 'waiting for nzb download', label) if progressDialog.iscanceled(): progressDialog.close() log("is_nzb_home: waiting for nzb: canceled") # Fix for hang when playing .strm time.sleep(1) xbmc.Player().stop() if sab_nzo_id is None and sab_nzo_id_init is not None: sab_nzo_id = sab_nzo_id_init #Trying to delete both the queue and history if sab_nzo_id is not None: pause = SABNZBD.pause_queue(id=sab_nzo_id) log("is_nzb_home: pause: sab_nzo_id: %s msg: %s" % (sab_nzo_id, pause)) time.sleep(3) delete_msg = SABNZBD.delete_queue('',sab_nzo_id) log("is_nzb_home: delete_queue: sab_nzo_id: %s nzbname: %s msg: %s" % (sab_nzo_id, nzbname, delete_msg)) if not "ok" in delete_msg: delete_msg = SABNZBD.delete_history('',sab_nzo_id) log("is_nzb_home: delete_history: sab_nzo_id: %s nzbname: %s msg: %s" % (sab_nzo_id, nzbname, delete_msg)) else: log("is_nzb_home: failed removing %s from the queue" % nzbname) iscanceled = True break time.sleep(1) seconds += 1 if not iscanceled: switch = SABNZBD.switch(0, '', sab_nzo_id) log("is_nzb_home: switch: sab_nzo_id: %s msg: %s" % (sab_nzo_id, switch)) if not "ok" in switch: progressDialog.update(0, 'Failed to prioritize the nzb!') time.sleep(1) # Dont add meta data for local nzb's if type == 'addurl': t = Thread(target=save_nfo, args=(folder,)) t.start() progressDialog.close() return True, sab_nzo_id else: progressDialog.close() return False, sab_nzo_id else: progressDialog.close() log("is_nzb_home: failed adding nzb to SAB") # Fix for hang when playing .strm xbmc.Player().stop() utils.notification("Request to SABnzbd failed!") return False, sab_nzo_id else: switch = SABNZBD.switch(0,'' , sab_nzo_id) log("is_nzb_home: switch: sab_nzo_id: %s msg: %s" % (sab_nzo_id, switch)) if not "ok" in switch: utils.notification("Failed to prioritize the nzb!") # TODO make sure there is also a NZB in the queue return True, sab_nzo_id
Usage: auto_rename.py [--debug] [--notify] auto_rename.py (-h | --help) auto_rename.py --version Options: -h --help Show this screen. --version Show version. --debug Debug mode, no files are actually renamed. """ args = docopt(doc, version='Auto Renamer 1.0 Beta') DEBUG = args["--debug"] show_notifications = args["--notify"] notification("Running RENAME script...", show_notifications) DOWNLOAD_DIR = HOME_DIR("Downloads") HDD_DIR = path("/media/iynaix/9b528a0a-22e7-410a-8bad-a4f52e97d407") #handle downloaded tv episodes move_tv_episodes() #handle downloaded movies move_movies() #folders where the files will be renamed RENAME_DIRS = [ HOME_DIR('Videos/WATCHED'), DOWNLOAD_DIR, ]
def event_main_filter(event): ''' 判断事件中是否存在可能的UAC绕过行为 ''' record = win32evtlog.EvtRender(event, win32evtlog.EvtRenderEventXml) record_dict = xmltodict.parse(record) # 转换为本地时区 evt_local_time = utc_to_local( record_dict['Event']['System']['TimeCreated']['@SystemTime']) record_dict['Event']['System']['TimeCreated'][ '@SystemTime'] = evt_local_time temp_data = {} for data in record_dict['Event']['EventData']['Data']: if '#text' in data: temp_data[data['@Name']] = data['#text'] elif data == None or data == 'None': temp_data = {} else: temp_data[data['@Name']] = None record_dict['Event']['EventData'] = temp_data evt_id = int(record_dict['Event']['System']['EventID']) if evt_id == 1: image = str(record_dict['Event']['EventData']['Image']) parent_image = str(record_dict['Event']['EventData']['ParentImage']) if parent_image == "C:\\Windows\\System32\\services.exe": service_outlier_executables_history[image] = 0 if 'cmd.exe' in image: outlier_parents_of_cmd_history[parent_image] = 0 # events_by_id[evt_id].append({'image': record_dict['Event']['EventData']['Image']}) if 'ParentCommandLine' in record_dict['Event']['EventData']: # COM-ICMLuaUtils-bypassUAC # 'C:\\WINDOWS\\system32\\DllHost.exe /Processid:{3E5FC7F9-9A51-4367-9063-A120244FBEC7}': if '{3E5FC7F9-9A51-4367-9063-A120244FBEC7}' in \ record_dict['Event']['EventData']['ParentCommandLine'].upper(): print('COM-ICMLuaUtils-bypassUAC') print(record_dict['Event']['EventData']['ParentCommandLine']) notification('COM-ICMLuaUtils-bypassUAC Detected!') # 判断是不是会被劫持的自动提权exe启动,是则检查对应的会被劫持的路径。 for ex in reg_hijack_dict: if (image.lower().startswith(r'C:\Windows\WinSxS'.lower()) or image.lower().startswith(r'C:\Windows\System32'.lower()) ) and ex.lower() in image.lower(): # check reg symlink sym_path = reg_symhij_check(reg_hijack_dict[ex]) if sym_path != None: print('Possible registry UAC Hijack with symlink!') print(f'Path:{sym_path}') notification('Possible registry UAC Hijack with symlink!', f'Path:{sym_path}') # if evt_id == 2: # events_by_id[evt_id].append({'image': record_dict['Event']['EventData']['Image'], # 'target name': record_dict['Event']['EventData']['TargetFilename']}) # SYSMON EVENT ID 6 : DRIVER LOADED INTO KERNEL [DriverLoad] if evt_id == 6: if record_dict['Event']['EventData'][ 'Signature'] != 'Microsoft Windows': events_by_id[evt_id].append({ 'ImageLoaded': record_dict['Event']['EventData']['ImageLoaded'], 'Signature': record_dict['Event']['EventData']['Signature'] }) # SYSMON EVENT ID 7 : DLL (IMAGE) LOADED BY PROCESS [ImageLoad] if evt_id == 7: if record_dict['Event']['EventData'][ 'Signature'] != 'Microsoft Windows': events_by_id[evt_id].append({ 'Image': record_dict['Event']['EventData']['Image'], 'ImageLoaded': record_dict['Event']['EventData']['ImageLoaded'] }) # dotLocal 被劫持dll的加载 current = events_by_id[evt_id][-1] if '.exe.local\\' in current['ImageLoaded'].lower(): print("dotLocal DLL hijack detected") print(events_by_id[evt_id][-1]) notification( "dotLocal DLL hijack detected", 'Image: {}\nLib: {}'.format(current['Image'], current['ImageLoaded'])) # SYSMON EVENT ID 8 : REMOTE THREAD CREATED [CreateRemoteThread] if evt_id == 8: # 远程线程注入 events_by_id[evt_id].append({ 'SourceProcessId': record_dict['Event']['EventData']['SourceProcessId'], 'SourceImage': record_dict['Event']['EventData']['SourceImage'], 'TargetProcessId': record_dict['Event']['EventData']['TargetProcessId'], 'TargetImage': record_dict['Event']['EventData']['TargetImage'], 'StartAddress': record_dict['Event']['EventData']['StartAddress'], 'StartModule': record_dict['Event']['EventData']['StartModule'], 'StartFunction': record_dict['Event']['EventData']['StartFunction'] }) print("RemoteThreadCreate detected") print(events_by_id[evt_id][-1]) notification( "RemoteThreadCreate detected", 'Source: {}\nTarget: {}'.format( events_by_id[evt_id][-1]['SourceImage'], events_by_id[evt_id][-1]['TargetImage'])) # SYSMON EVENT ID 11 : FILE CREATED [FileCreate] if evt_id == 11: events_by_id[evt_id].append({ 'ProcessId': record_dict['Event']['EventData']['ProcessId'], 'Image': record_dict['Event']['EventData']['Image'], 'TargetFilename': record_dict['Event']['EventData']['TargetFilename'] }) current = events_by_id[evt_id][-1] # dotLocal机制的DLL劫持检测 - 判断是否有文件创建在'*.exe.local/'的路径内 if '.exe.local\\' in current['TargetFilename'].lower(): print("dotLocal DLL hijack file create!") print(events_by_id[evt_id][-1]) notification( "dotLocal DLL hijack file create!", 'Image: {}\nFile: {}'.format(current['Image'], current['TargetFilename'])) # SYSMON EVENT ID 12 & 13 & 14 : REGISTRY MODIFICATION [RegistryEvent] if evt_id == 13: events_by_id[evt_id].append({ 'Image': record_dict['Event']['EventData']['Image'], 'TargetObject': record_dict['Event']['EventData']['TargetObject'] }) current = events_by_id[evt_id][-1] # 打印出得到的注册表事件 - 调试用 # print("Registry value set") # print(len(record_dict['Event']['EventData']['Details'])) # print(record_dict['Event']['EventData']['Details'][:5]) # print(type(record_dict['Event']['EventData']['Details'])) # print(current) if '[Reflection.Assembly]::Load' in record_dict['Event']['EventData']['Details'] and \ "[Microsoft.Win32.Registry]" in record_dict['Event']['EventData']['Details']: print("Fileless Attack - Living off the land.") print(current) notification("Fileless Attack!") if not record_dict['Event']['EventData']['TargetObject'].startswith( 'HKLM'): # possibly HKCU target_path = record_dict['Event']['EventData']['TargetObject'] target = target_path[target_path.rfind('\\') + 1:].lower() # 检测windir环境变量改变 - 检测部分通过windir劫持的UAC绕过方法 if target == 'windir': print("Possible UACBypass: windir hijack!") print(current) notification("Possible UACBypass: windir hijack!") # 检测COR_ENABLE_PROFILING环境变量改变 - 检测部分通过C# profile的UAC绕过方法 elif target.upper() == 'COR_ENABLE_PROFILING' or target.upper( ) == 'COR_PROFILER': print("Possible UACBypass: C# profile!") print(current) notification("Possible UACBypass: C# profile!") # print(target_path) value = record_dict['Event']['EventData']['Details'] # 对每个可能被劫持路径判断一下,看看当前修改的注册表是不是用来劫持的位置 for path in reg_hijack_dict.values(): # print((target_path, path)) if path in target_path: print('Possible registry UAC Hijack!') print(f'Path:{target_path}\nValue:{value}') notification('Possible registry UAC Hijack!', f'Path:{target_path}\nValue:{value}')
def is_nzb_home(params): log("is_nzb_home: params: %s" % params) get = params.get nzb = utils.unquote_plus(get("nzb")) nzbname = m_nzb.Nzbname(utils.unquote_plus(get("nzbname"))).final_name folder = utils.join(INCOMPLETE_FOLDER, os.path.join(nzbname, '')) iscanceled = False type = get('type', 'addurl') sab_nzo_id = sabnzbd.nzo_id(nzbname, nzb) log("is_nzb_home: folder: %s sab_nzo_id: %s" %(folder, sab_nzo_id)) if sab_nzo_id is None: nzo_id = sabnzbd.nzo_id_history(nzbname) else: nzo_id = sab_nzo_id log("is_nzb_home: nzo_id: %s" % nzo_id) if not utils.dir_exists(folder, nzo_id): progressDialog = xbmcgui.DialogProgress() progressDialog.create('Pneumatic', 'Sending request to SABnzbd') category = get_category() # correct wrong type mode if nzb.startswith('http'): type = "addurl" log("is_nzb_home: type changed to addurl") elif type == 'addurl': type = 'add_file' log("is_nzb_home: type changed to add_file") if type == 'addurl': type, nzb = nzb_cache(type, nzb, nzbname) # SABnzbd and URI should be latin-1 encoded if type == 'addurl': response = sabnzbd.addurl(nzb.encode('latin-1'), nzbname, category=category) # add_local will not work on remote shares, thus add_file elif type == 'add_file' or type == 'add_local': response = sabnzbd.add_file(nzb.encode('latin-1'), category=category) log("is_nzb_home: type: %s response: %s" %(type, response)) if "ok" in response: progressDialog.update(0, 'Request to SABnzbd succeeded', 'waiting for nzb download') seconds = 0 timer = 0 #SABnzbd uses nzb url as name until it has downloaded the nzb file sab_nzo_id_init = sabnzbd.nzo_id(nzbname, nzb) log("is_nzb_home: sab_nzo_id_init: %s" % sab_nzo_id_init) while not (sab_nzo_id and utils.exists_incomplete(folder)): # Ask user what incomplete dir is right every 10s if timer > 9: timer = 0 folder, nzbname = find_incomplete(folder, nzbname) sab_nzo_id = sabnzbd.nzo_id(nzbname) label = str(seconds) + " seconds" log("is_nzb_home: waiting for nzb: sab_nzo_id: %s for: %s" % (sab_nzo_id, label)) progressDialog.update(0, 'Request to SABnzbd succeeded', 'waiting for nzb download', label) if progressDialog.iscanceled(): progressDialog.close() log("is_nzb_home: waiting for nzb: canceled") # Fix for hang when playing .strm time.sleep(1) xbmc.Player().stop() if sab_nzo_id is None and sab_nzo_id_init is not None: sab_nzo_id = sab_nzo_id_init #Trying to delete both the queue and history if sab_nzo_id is not None: pause = sabnzbd.nzo_pause(sab_nzo_id) #log("rassi pause") log("is_nzb_home: pause: sab_nzo_id: %s msg: %s" % (sab_nzo_id, pause)) time.sleep(3) #log("rassi before delete") delete_msg = sabnzbd.nzo_delete_files(sab_nzo_id) log("is_nzb_home: delete_queue: sab_nzo_id: %s nzbname: %s msg: %s" % (sab_nzo_id, nzbname, delete_msg)) if not "ok" in delete_msg: delete_msg = sabnzbd.nzo_delete_history_files(sab_nzo_id) log("is_nzb_home: delete_history: sab_nzo_id: %s nzbname: %s msg: %s" % (sab_nzo_id, nzbname, delete_msg)) #log("rassi after delete") else: log("is_nzb_home: failed removing %s from the queue" % nzbname) iscanceled = True break time.sleep(1) seconds += 1 timer += 1 if not iscanceled: switch = sabnzbd.nzo_switch(sab_nzo_id, 0).replace('\n', '') log("is_nzb_home: switch: sab_nzo_id: %s msg: %s" % (sab_nzo_id, switch)) if not "0" in switch: progressDialog.update(0, 'Failed to prioritize the nzb!') time.sleep(1) # Dont add meta data for local nzb's if type == 'addurl': t = Thread(target=save_nfo, args=(folder,)) t.start() progressDialog.close() return True, sab_nzo_id else: progressDialog.close() return False, sab_nzo_id else: progressDialog.close() log("is_nzb_home: failed adding nzb to SAB") # Fix for hang when playing .strm xbmc.Player().stop() utils.notification("Request to SABnzbd failed!") return False, sab_nzo_id else: switch = sabnzbd.nzo_switch(sab_nzo_id, 0).replace('\n', '') log("is_nzb_home: switch: sab_nzo_id: %s msg: %s" % (sab_nzo_id, switch)) if not "0" in switch: utils.notification("Failed to prioritize the nzb!") # TODO make sure there is also a NZB in the queue return True, sab_nzo_id
headers={ "User-Agent": "NTV-XBMC-" + ADDON.getAddonInfo('version') }).content data = json.loads(link) rtmp = data['src'] rtmp = '%s' % (rtmp) cmd = os.path.join(ADDON.getAddonInfo('path'), 'rtmpdump', rtmpdumpFilename()) cmd += ' -V --stop ' + str(duration) cmd += ' --live ' cmd += ' --flv "' + recordPath + re.sub('[:\\/*?\<>|"]+', '', title) + '.flv"' cmd += ' --rtmp "' + rtmp cmd += '"' print "Record.py command:" print cmd utils.notification('Recording %s started' % title) if ADDON.getSetting('os') == '11': runCommand(cmd, libpath=None) else: libpath = libPath() runCommand(cmd, libpath=libpath) utils.notification('Recording %s complete' % title)
RecordingDisabled = False else: time.sleep(1) #print 'os.access(/home/hans/.xbmc/addon/plugin.video.wozboxntv/rtmpdump/linux32/rtmpdump, os.X_OK)= FAIL' recordings.updateRecordingPlanned(nameAlarm, '[COLOR red]Set this program executable:[/COLOR] %s' % (rtmpdumpEXE)) utils.notification('Recording %s [COLOR red]NOT possible! Set this program executable:[/COLOR] %s' % (title,rtmpdumpEXE)) time.sleep(1000) RecordingDisabled = True """ RecordingDisabled = False #print 'record.py: nameAlarm= %s' % (str(repr(nameAlarm))) #xbmc.log( 'record.py: LoopCountMax= %s' % (str(repr(LoopCountMax)))) recordPath = xbmc.translatePath(os.path.join(ADDON.getSetting('record_path'))) xbmc.log( 'record.py: recordPath= %s' %recordPath) if not utils.folderwritable(recordPath): utils.notification('Recording %s [COLOR red]FAILED - You must set the recording path writable![/COLOR]' % title) else: net=net.Net() datapath = xbmc.translatePath(ADDON.getAddonInfo('profile')) cookie_path = os.path.join(datapath, 'cookies') loginurl = definition.getBASEURL() + '/index.php?' + recordings.referral()+'c=3&a=4' ## 2016-02-26 Mikey1234 ver 3.4.6 username = ADDON.getSetting('user') password = md5(ADDON.getSetting('pass')).hexdigest() data = {'email': username, 'psw2': password, 'rmbme': 'on'} headers = {'Host':definition.getBASEURL().replace('http://',''),
def forbidden(message): """ helper function for check_* decorators. """ utils.notification(request, message) return HttpResponseForbidden(message)
print 'recordffmpeguri.py: sys.argv= %s' %(str(repr(sys.argv))) try: program = sys.argv[0] uri = sys.argv[1].replace('AAabBB',' ').replace('aAabBb','?').replace('BBabAA','=').replace('xXx',' ').replace('###',',') title = sys.argv[2] except: pass title = 'DRarkiv Video' try: #print os.environ print os.environ['OS'] #put in LOG except: pass if not ADDON.getSetting('RecordFromTVguide') == 'true': utils.notification('Recording %s [COLOR red]NOT enabled[/COLOR]' % (title)) else: LoopCountMax = int(ADDON.getSetting('LoopCount')) recordPath = xbmc.translatePath(os.path.join(ADDON.getSetting('record_path'))) print 'recordPath= %s' %recordPath if not utils.folderwritable(recordPath): utils.notification('Recording %s [COLOR red]FAILED - You must set the recording path writable![/COLOR]' % title) else: datapath = xbmc.translatePath(ADDON.getAddonInfo('profile')) nowHM=datetime.datetime.today().strftime('%H:%M:%S') #print 'recorduri.py5: title= %s, LoopCount= %s at %s' % (repr(title),repr(0),nowHM) duration = ADDON.getSetting('RecordFromTVguideDurationMinutes') cmdoption='' qrecord = xbmcgui.Dialog() arecord = qrecord.yesno(ADDON.getAddonInfo('name'),'Do you want to record?', '' ,title) xbmc.log('recorduriffmpeg: answer= %s' % repr(arecord))
title = sys.argv[5] url = 'http://www.ntv.mx/index.php?c=6&a=0&mwAction=content&xbmc=1&mwData={"id":%s,"type":"tv"}' % cat link = net.http_GET(url).content data = json.loads(link) rtmp = data['src'] playpath = rtmp.split('live/')[1] app = 'live?'+rtmp.split('?')[1] rtmp = '%s --swfUrl=http://ntv.mx/inc/grindplayer/GrindPlayer.swf --app=%s --playpath=%s' % (rtmp, app, playpath) rtmp += ' --live' rtmp += ' --stop ' + str(duration) cmd = os.path.join(ADDON.getAddonInfo('path'),'rtmpdump', rtmpdumpFilename()) #cmd = 'c:/rtmp/rtmpdump.exe' cmd += ' --flv "' + recordPath + re.sub('[:\\/*?\<>|"]+', '', title) + '.flv"' cmd += ' --rtmp ' + rtmp print "Record.py command:" print cmd utils.notification('Recording %s started' % title) if ADDON.getSetting('os')=='11': runCommand(cmd, libpath=None) else: libpath = libPath() runCommand(cmd, libpath=libpath) utils.notification('Recording %s complete' % title)
def pre_play(nzbname, **kwargs): log("pre_play: nzbname: %s kwargs: %s" % (nzbname, kwargs)) mode = kwargs.get('mode', None) sab_nzo_id = kwargs.get('nzo', None) iscanceled = False folder = utils.join(INCOMPLETE_FOLDER, os.path.join(nzbname, '')) folder_one = folder + '.1' if utils.exists(os.path.join(folder_one, '')): folder = folder_one if sab_nzo_id is None: sab_nzo_id_history = sabnzbd.nzo_id_history(nzbname) nzf_list = utils.dir_to_nzf_list(folder) else: nzo = Nzo(sab_nzo_id) nzf_list = nzo.nzf_list() sab_nzo_id_history = None sorted_rar_nzf_list = utils.sorted_rar_nzf_file_list(nzf_list) # TODO # If we cant find any rars in the queue, we have to wait for SAB # and then guess the names... # if len(nzf_list) == 0: # iscanceled = get_nzf(folder, sab_nzo_id, None) is_movie_in_rar = True if len(sorted_rar_nzf_list) == 0: # look for other playable files multi_nzf_list = sorted_nzf_list = utils.sorted_movie_nzf_file_list(nzf_list) if len(multi_nzf_list) > 0: is_movie_in_rar = False else: multi_nzf_list = utils.sorted_multi_arch_nzf_list(sorted_rar_nzf_list) sorted_nzf_list = sorted_rar_nzf_list clean_sorted_nzf_list = utils.nzf_diff_list(sorted_nzf_list, multi_nzf_list) if len(multi_nzf_list) > 0: # Loop though all multi archives and add file to the play_list = [] for nzf in multi_nzf_list: if sab_nzo_id is not None: response = set_streaming(sab_nzo_id) log("pre_play: set_streaming: %s" % response) t = Thread(target=nzf_to_bottom, args=(sab_nzo_id, nzf_list, sorted_nzf_list,)) t.start() iscanceled = get_nzf(folder, sab_nzo_id, nzf) if iscanceled: break else: if is_movie_in_rar: # RAR ANALYSYS # in_rar_file_list = utils.rar_filenames(folder, nzf.filename) movie_list = utils.sort_filename(in_rar_file_list) log("pre_play: folder: %s nzf.filename: %s in_rar_file_list: %s" % (folder, nzf.filename, in_rar_file_list)) else: movie_list = [os.path.join(folder, nzf.filename)] # Make sure we have a movie if not (len(movie_list) >= 1): utils.notification("Not a movie!") log("pre_play: no movie in movie_list") break # Who needs sample? movie_no_sample_list = utils.no_sample_list(movie_list) # If auto play is enabled we skip samples in the play_list if AUTO_PLAY and mode is not MODE_INCOMPLETE_LIST: for movie_file in movie_no_sample_list: play_list.append(nzf.filename) play_list.append(movie_file) else: for movie_file in movie_list: play_list.append(nzf.filename) play_list.append(movie_file) # If the movie is a .mkv or .mp4 we need the last rar if utils.is_movie_mkv(movie_list) and sab_nzo_id and is_movie_in_rar: # If we have a sample or other file, the second rar is also needed.. if len(in_rar_file_list) > 1: second_nzf = clean_sorted_nzf_list[1] iscanceled = get_nzf(folder, sab_nzo_id, second_nzf) last_nzf = clean_sorted_nzf_list[-1] iscanceled = get_nzf(folder, sab_nzo_id, last_nzf) if iscanceled: break if iscanceled: log("pre_play: get_nzf: canceled") return else: rar_file_list = [x.filename for x in sorted_nzf_list] if (len(rar_file_list) >= 1) or (not is_movie_in_rar and len(movie_list) >= 1): if AUTO_PLAY and ( mode is None or mode is MODE_STRM): video_params = dict() if not mode: video_params['mode'] = MODE_AUTO_PLAY else: video_params['mode'] = MODE_STRM video_params['play_list'] = utils.quote_plus(';'.join(play_list)) video_params['file_list'] = utils.quote_plus(';'.join(rar_file_list)) video_params['folder'] = utils.quote_plus(folder) video_params['nzoid'] = sab_nzo_id video_params['nzoidhistory'] = sab_nzo_id_history return play_video(video_params) else: return playlist_item(play_list, rar_file_list, folder, sab_nzo_id, sab_nzo_id_history) else: utils.notification("No rar\'s in the NZB!") log("pre_play: no rar\'s in the NZB") return else: utils.notification("No playable files found!") log("pre_play: no playable files found") #log("the_end(folder, True, sab_nzo_id, sab_nzo_id_history): %s, %s, %s" % (folder, sab_nzo_id, sab_nzo_id_history)) the_end(folder, True, sab_nzo_id, sab_nzo_id_history) return
def RecursiveRecordingsPlanned(SearchAllFavorites): #import recordings import utils global AccessError AccessError = [] #print "findrecursive.py4" # SearchRecursiveIn 0= Only Selected Channel, 1= Favorite Channels and 2= All My Channels cat = ADDON.getSetting('SearchRecursiveIn') print 'findrecursive.py RecursiveRecordingsPlanned: cat= %s, SearchAllFavorites= %s' % (repr(cat), repr(SearchAllFavorites)) if locking.isAnyRecordLocked(): locking.scanUnlockAll() return elif locking.isAnyScanLocked(): return else: locking.scanLock(SearchAllFavorites) if not locking.isScanLocked(SearchAllFavorites): return print 'findrecursive.py RUNNING RecursiveRecordingsPlanned: cat= %s, SearchAllFavorites= %s' % (repr(cat), repr(SearchAllFavorites)) ADDON.setSetting('RecursiveSearch','true') if int(cat)>0 or ((not SearchAllFavorites == 'NotAllFavorites')and(not SearchAllFavorites == 'Once')and(not SearchAllFavorites == 'Hour')): # find all channels i favorite view # cat = '-1' # DUMMY -1 Favorites, -2 My Channels #print "findrecursive.py5" net.set_cookies(cookie_jar) imageUrl=definition.getBASEURL() + '/res/content/tv/' now= datetime.datetime.today().strftime('%Y-%m-%d %H:%M:%S').replace(' ','%20') url='&mwAction=category&xbmc=1&mwData={"id":"-%s","time":"%s","type":"tv"}'%(cat,now) link = net.http_GET(site+url, headers={'User-Agent' : UA}).content data = json.loads(link) channels=data['contents'] #print 'findrecursive.py6 cat= %s, CHANNELS= %s' % (cat,str(repr(channels))) offset= int(data['offset']) from operator import itemgetter #Sort channels by name! channels = sorted(channels, key=itemgetter('name')) uniques=[] for field in channels: #endTime = field['time_to'] name = field['name'].encode("utf-8") channel = field['id'] #whatsup = field['whatsup'].encode("utf-8") #description = field['descr'].encode("utf-8") #r=re.compile("(.+?)-(.+?)-(.+?) (.+?):(.+?):(.+?)") #matchend = r.search(endTime) #endyear = matchend.group(1) #endmonth = matchend.group(2) #endday = matchend.group(3) #endhour = matchend.group(4) #endminute = matchend.group(5) #endDate = datetime.datetime(int(endyear),int(endmonth),int(endday),int(endhour),int(endminute)) + datetime.timedelta(seconds = offset) #print "findrecursive.py6" if channel not in uniques: #print "findrecursive.py7" uniques.append(channel) #if ADDON.getSetting('tvguide')=='true': # name='%s - [COLOR yellow]%s[/COLOR]'%(name,whatsup) #addDir(name,'url',200,imageUrl+recordings.icon(channel)+'.png',channel,'',description,now,endDate,whatsup) #setView('movies', 'channels-view') #print 'findrecursive.py8 favorite channels= %s' % repr(uniques) #print "findrecursive.py9" offset=0 conn = recordings.getConnection() c = conn.cursor() c.execute("SELECT DISTINCT cat, name, start, end, alarmname, description, playchannel FROM recordings_adc") recordingsE = c.fetchall() from operator import itemgetter # Put recursive recordings changed last - first recordingsC = sorted(recordingsE, key=itemgetter(2), reverse=True) #print "findrecursive.py10" for index in range(0, len(recordingsC)): if locking.isAnyRecordLocked(): locking.scanUnlockAll() ADDON.setSetting('RecursiveSearch','false') return if not locking.isScanLocked(SearchAllFavorites): ADDON.setSetting('RecursiveSearch','false') return #print 'findrecursive.py11: idx=%s sdt=%s edt=%s nam=%s' %(repr(index),repr(recordings.parseDate(recordingsC[index][2])),repr(recordings.parseDate(recordingsC[index][3])),repr(recordingsC[index][1])) if isinstance(recordings.parseDate(recordingsC[index][2]), datetime.date) and isinstance(recordings.parseDate(recordingsC[index][3]), datetime.date) and 'Recursive:' in recordingsC[index][1]: #print "findrecursive.py12" if int(ADDON.getSetting('SearchRecursiveIn')) > 0 or ((not SearchAllFavorites == 'NotAllFavorites')and(not SearchAllFavorites == 'Once')and(not SearchAllFavorites == 'Hour')): #print "findrecursive.py13" if not recordingsC[index][0] in uniques: findrecursiveinplaychannel(recordingsC[index][0],recordingsC[index][1],index) # Allways search channel in record if ADDON.getSetting('NotifyOnSearch')=='true' and not '[COLOR orange]' in recordingsC[index][1]: utils.notification('Find%s [COLOR green]complete in own channel[/COLOR]' % recordingsC[index][1]) for cat in uniques: #print "findrecursive.py14" findrecursiveinplaychannel(cat,recordingsC[index][1],index) if ADDON.getSetting('NotifyOnSearch')=='true' and not '[COLOR orange]' in recordingsC[index][1]: #print "findrecursive.py15" utils.notification('Find%s [COLOR green]complete[/COLOR]' % recordingsC[index][1]) else: #print "findrecursive.py16" findrecursiveinplaychannel(recordingsC[index][0],recordingsC[index][1],index) if ADDON.getSetting('NotifyOnSearch')=='true' and not '[COLOR orange]' in recordingsC[index][1]: #print "findrecursive.py17" utils.notification('Find%s [COLOR green]complete[/COLOR] in selected channel: %s' % (recordingsC[index][1], recordingsC[index][0])) #print "findrecursive.py18" try: conn.commit() #print 'recordings.py conn.commit OK' except: pass #print 'recordings.py conn.commit failed!' c.close() #print "findrecursive.py" #xbmc.executebuiltin("Container.Refresh") if ADDON.getSetting('NotifyOnSearch')=='true': #print "findrecursive.py19" utils.notification('Find all recursives [COLOR green]complete[/COLOR]') #print "findrecursive.py20" locking.scanUnlockAll() ADDON.setSetting('RecursiveSearch','false') return
def play_video(params): log("play_video: params: %s" % params) get = params.get mode = get("mode") file_list = get("file_list") file_list = utils.unquote_plus(file_list).split(";") play_list = get("play_list") play_list = utils.unquote_plus(play_list).split(";") folder = get("folder") folder = utils.unquote_plus(folder) # We might have deleted the path if utils.exists(folder): if len(file_list) > 0 and not play_list[1].endswith(play_list[0]): # we trick xbmc to play avi by creating empty rars if the download is only partial utils.write_fake(file_list, folder) # Prepare potential file stacking if (len(play_list) > 2): rar = [] for arch_rar, movie_file in zip(play_list[0::2], play_list[1::2]): raruri = "rar://" + utils.rarpath_fixer(folder, arch_rar) + "/" + movie_file rar.append(raruri) raruri = 'stack://' + ' , '.join(rar) else: raruri = "rar://" + utils.rarpath_fixer(folder, play_list[0]) + "/" + play_list[1] uri = raruri else: # we have a plain file if (len(play_list) > 2): uri = "stack://%s" % ' , '.join(play_list[1::2]) else: uri = play_list[1] log("play_video: uri: %s" % uri) info = nfo.NfoLabels() item = xbmcgui.ListItem(info.info_labels['title'], iconImage='DefaultVideo.png', thumbnailImage=info.thumbnail) item.setInfo(type="Video", infoLabels=info.info_labels) item.setPath(uri) item.setProperty("IsPlayable", "true") xbmcplugin.setContent(HANDLE, 'movies') wait = 0 player = xbmcplayer.XBMCPlayer(xbmc.PLAYER_CORE_AUTO) player.sleep(1000) if mode == MODE_AUTO_PLAY or mode == MODE_LIST_PLAY: player.play( uri, item ) log("play_video: player.play uri: %s" % uri) else: xbmcplugin.setResolvedUrl(handle=HANDLE, succeeded=True, listitem=item) log("play_video: setResolvedUrl uri: %s" % uri) removed_fake = False while player.is_active: player.sleep(500) wait+= 1 if player.is_playing and not removed_fake: utils.remove_fake(file_list, folder) removed_fake = True if player.is_stopped: the_end(folder, player.is_stopped) player.is_active = False elif player.is_ended: the_end(folder) player.is_active = False elif wait >= 6000 and not player.isPlayingVideo(): utils.notification("Error playing file!") break if not removed_fake: utils.remove_fake(file_list, folder) else: utils.notification("File deleted") time.sleep(1) xbmc.executebuiltin("Action(ParentDir)") return
#!/usr/bin/python # -*- coding: utf-8 -*- import utils,datetime,recordings import xbmcaddon now=datetime.datetime.today() RecordingsActive = recordings.getRecordingsActive(now,now) nowHM=datetime.datetime.today().strftime('%H:%M') if RecordingsActive == '': utils.notification('Clock [COLOR green]%s[/COLOR] %s' % (nowHM, RecordingsActive)) else: ADDON = xbmcaddon.Addon(id='plugin.video.wozboxntv') LastRecordProcess = ADDON.getSetting('LastRecordProcess') Pname = str(repr(LastRecordProcess)) #ADDON.setSetting('LastRecordProcess', Pname) utils.notification('Clock [COLOR orange]%s[/COLOR] %s' % (nowHM, Pname))
def main(argv=sys.argv): active = True try: while active: screen = curses.initscr() screen.border(0) screen.addstr(2, 2, " \u2022\u2022") screen.addstr(3, 2, " \u2022\u2022") screen.addstr( 4, 2, " \u2022\u2022\u2022\u2022\u2022\u2022 \ \u2022\u2022\u2022\u2022\u2022\u2022 \ \u2022\u2022\u2022\u2022\u2022\u2022\u2022", ) screen.addstr( 5, 2, " \u2022\u2022 \u2022\u2022 \ \u2022\u2022 \u2022\u2022 \u2022\u2022", ) screen.addstr( 6, 2, " \u2022\u2022 \u2022 \ \u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022 \u2022\u2022 \u2022\u2022 \ - Once a day", ) screen.addstr( 7, 2, " \u2022\u2022 \u2022\u2022 \u2022\u2022 \ \u2022\u2022 \u2022\u2022 \u2022\u2022", ) screen.addstr( 8, 2, " \u2022\u2022\u2022\u2022\u2022\u2022 \ \u2022\u2022\u2022\u2022\u2022\u2022\u2022 \ \u2022\u2022\u2022\u2022\u2022\u2022\u2022", ) screen.addstr(11, 4, "1 - Mailsettings") screen.addstr(12, 4, "2 - Time Settings") screen.addstr(13, 4, "3 - Notifications") screen.addstr(14, 4, "4 - Exit") screen.refresh() choice = screen.getch() if choice == ord("4"): active = False curses.endwin() elif choice == ord("1"): # TODO: write function utils.mail() curses.endwin() elif choice == ord("2"): # TODO: write function utils.time() curses.endwin() elif choice == ord("3"): utils.notification() curses.endwin() except Exception as e: curses.endwin() windows = True if platform.system() == "Windows" else False clear = "cls" if windows else "clear" subprocess.run(clear) print("Once-a-day exited because of an Exception:\n {}".format(e))
def play_video(params): log("play_video: params: %s" % params) get = params.get mode = get("mode") file_list = get("file_list") file_list = utils.unquote_plus(file_list).split(";") play_list = get("play_list") play_list = utils.unquote_plus(play_list).split(";") folder = get("folder") folder = utils.unquote_plus(folder) # We might have deleted the path if utils.exists_incomplete(folder): if len(file_list) > 0 and not play_list[1].endswith(play_list[0]): # we trick xbmc to play avi by creating empty rars if the download is only partial utils.write_fake(file_list, folder) # Prepare potential file stacking if (len(play_list) > 2): rar = [] for arch_rar, movie_file in zip(play_list[0::2], play_list[1::2]): raruri = "rar://" + utils.rarpath_fixer(folder, arch_rar) + "/" + movie_file rar.append(raruri) raruri = 'stack://' + ' , '.join(rar) else: raruri = "rar://" + utils.rarpath_fixer(folder, play_list[0]) + "/" + play_list[1] uri = raruri else: # we have a plain file if (len(play_list) > 2): uri = "stack://%s" % ' , '.join(play_list[1::2]) else: uri = play_list[1] log("play_video: uri: %s" % uri) info = nfo.NfoLabels() item = xbmcgui.ListItem(info.info_labels['title'], iconImage='DefaultVideo.png', thumbnailImage=info.thumbnail) item.setInfo(type="Video", infoLabels=info.info_labels) item.setPath(uri) item.setProperty("IsPlayable", "true") xbmcplugin.setContent(HANDLE, 'movies') wait = 0 player = xbmcplayer.XBMCPlayer(xbmc.PLAYER_CORE_AUTO) player.sleep(1000) if mode == MODE_AUTO_PLAY or mode == MODE_LIST_PLAY: player.play( uri, item ) log("play_video: player.play uri: %s" % uri) else: xbmcplugin.setResolvedUrl(handle=HANDLE, succeeded=True, listitem=item) log("play_video: setResolvedUrl uri: %s" % uri) removed_fake = False while player.is_active: player.sleep(500) wait+= 1 if player.is_playing and not removed_fake: utils.remove_fake(file_list, folder) removed_fake = True if player.is_stopped: the_end(folder, player.is_stopped, params.get("nzoid"), params.get("nzoidhistory")) player.is_active = False elif player.is_ended: time.sleep(1) log("rassi: player.is_ended, player.is_stopped %s" % player.is_stopped) the_end(folder, True, params.get("nzoid"), params.get("nzoidhistory")) player.is_active = False elif wait >= 6000 and not player.isPlayingVideo(): utils.notification("Error playing file!") break if not removed_fake: utils.remove_fake(file_list, folder) else: utils.notification("File deleted") time.sleep(1) xbmc.executebuiltin("Action(ParentDir)") return
# -*- coding: utf-8 -*- import recordings, utils, locking import xbmcaddon, xbmc, datetime utils.log('service.py','Start') #PLUGIN='plugin.video.wozboxntv' #ADDON = xbmcaddon.Addon(id=PLUGIN) #ADDON = xbmcaddon.Addon(id='plugin.video.wozboxntv') import definition ADDON = definition.getADDON() #xbmc.log('service.py in %s' % ADDON.getAddonInfo('name')) utils.log('Version',utils.version()) utils.log('VersionDate',utils.versiondate()) try: Platform = utils.rtmpdumpFilename() if not Platform == '': utils.notification('[COLOR green]Platform found and set[/COLOR]') except: pass utils.log('FindPlatform','FAILED') # Put in LOG locking.recordUnlockAll() locking.scanUnlockAll() recordings.backupSetupxml() recordings.restoreLastSetupXml() recordings.ftvntvlist() ADDON.setSetting('allmessages','') ADDON.setSetting('RecursiveSearch','false') if ADDON.getSetting('enable_record')=='true': now = recordings.parseDate(datetime.datetime.now()) startDate=now - datetime.timedelta(days = 10) endDate=now + datetime.timedelta(days = 100) recordingsActive=recordings.getRecordingsActive(startDate, endDate)
import definition ADDON = definition.getADDON() #xbmc.log('recorduri.py: sys.argv= %s' %(str(repr(sys.argv)))) try: program = sys.argv[0] uri = sys.argv[1].replace('AAabBB',' ').replace('aAabBb','?').replace('BBabAA','=') title = sys.argv[2] except: pass title = 'DRarkiv-FilmOn Videos' try: xbmc.log('recorduri.py: os.environ= %s' % os.environ['OS'] ) #put in LOG except: pass if not ADDON.getSetting('RecordFromTVguide') == 'true': utils.notification('Recording %s [COLOR red]NOT enabled[/COLOR]' % (title)) else: LoopCountMax = int(ADDON.getSetting('LoopCount')) rtmpdumpEXEp = utils.rtmpdumpFilename() rtmpdumpEXE = os.path.join(ADDON.getAddonInfo('path'),'rtmpdump',rtmpdumpEXEp) xbmc.log('recorduri.py: stats os.F_OK: %s' % os.access(rtmpdumpEXE, os.F_OK)) xbmc.log('recorduri.py: stats os.W_OK: %s' % os.access(rtmpdumpEXE, os.W_OK)) xbmc.log('recorduri.py: stats os.X_OK: %s' % os.access(rtmpdumpEXE, os.X_OK)) #xbmc.log('1') if not xbmc.getCondVisibility('system.platform.windows'): if os.access(rtmpdumpEXE, os.X_OK): print 'Permissions ------ 0777 ----- GREAT !!' # Put in LOG else: print 'Permissions ----------------- BAD !!' # Put in LOG