Example #1
0
"""
Torrent streamer WSGI server
"""

import time
time.sleep(2)

import xbmc
import xbmcgui
from libs.server.wsgi_server import create_server
from simpleplugin import Addon

kodi_monitor = xbmc.Monitor()
addon = Addon()
_ = addon.initialize_gettext()
addon.log_notice('Starting Torrent Server...')

# A monkey-patch to set the necessary librorrent version
librorrent_addon = Addon('script.module.libtorrent')
orig_custom_version = librorrent_addon.get_setting('custom_version', False)
orig_set_version = librorrent_addon.get_setting('set_version', False)
librorrent_addon.set_setting('custom_version', 'true')
if addon.libtorrent_version == '1.0.9':
    librorrent_addon.set_setting('set_version', '4')
elif addon.libtorrent_version == '1.1.0':
    librorrent_addon.set_setting('set_version', '5')
elif addon.libtorrent_version == '1.1.1':
    librorrent_addon.set_setting('set_version', '6')
else:
    librorrent_addon.set_setting('set_version', '0')
Example #2
0
# coding: utf-8
# Created on: 25.03.2016
# Author: Roman Miroshnychenko aka Roman V.M. ([email protected])

import sys
import time
import xbmc
from simpleplugin import Addon
from libs.autodownloader import filter_torrents


addon = Addon()
monitor = xbmc.Monitor()
if not addon.enable_autodownload:
    addon.log_warning('Autodownload service is disabled.')
    sys.exit()
started = False
start_time = time.time()
while not monitor.abortRequested():
    if time.time() - start_time > 1800:  # Filter new torrents every 30 minutes
        filter_torrents()
        start_time = time.time()
    if not started:
        addon.log_notice('Autodownload service started.')
        started = True
        filter_torrents()
    xbmc.sleep(250)
addon.log_notice('Autodownload service stopped.')