-
Notifications
You must be signed in to change notification settings - Fork 55
/
library_service.py
115 lines (95 loc) · 5.24 KB
/
library_service.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# -*- coding: utf-8 -*-
# ------------------------------------------------------------
# streamondemand 4
# Copyright 2015 tvalacarta@gmail.com
#
# Distributed under the terms of GNU General Public License v3 (GPLv3)
# http://www.gnu.org/licenses/gpl-3.0.html
# ------------------------------------------------------------
# This file is part of streamondemand 4.
#
# streamondemand 4 is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# streamondemand 4 is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with streamondemand 4. If not, see <http://www.gnu.org/licenses/>.
# ------------------------------------------------------------
# Service for updating new episodes on library series
# ------------------------------------------------------------
from core import scrapertools
if scrapertools.wait_for_internet(retry=10):
# -- Update channels from repository streamondemand ------
try:
from core import update_channels
except:
logger.info("streamondemand.library_service Error in update_channels")
# ----------------------------------------------------------------------
# -- Update servertools and servers from repository streamondemand ------
try:
from core import update_servers
except:
logger.info("streamondemand.library_service Error in update_servers")
# ----------------------------------------------------------------------
import os
import xbmc
import imp
from core import config
from core import logger
from core.item import Item
from platformcode import library
logger.info("streamondemand.library_service Actualizando series...")
directorio = os.path.join(config.get_library_path(), "SERIES")
logger.info("directorio=" + directorio)
if not os.path.exists(directorio):
os.mkdir(directorio)
nombre_fichero_config_canal = os.path.join(config.get_library_path(), "series.xml")
if not os.path.exists(nombre_fichero_config_canal):
nombre_fichero_config_canal = os.path.join(config.get_data_path(), "series.xml")
try:
if config.get_setting("updatelibrary") == "true":
config_canal = open(nombre_fichero_config_canal, "r")
for serie in config_canal.readlines():
logger.info("streamondemand.library_service serie=" + serie)
serie = serie.split(",")
ruta = os.path.join(config.get_library_path(), "SERIES", serie[0])
logger.info("streamondemand.library_service ruta =#" + ruta + "#")
if os.path.exists(ruta):
logger.info("streamondemand.library_service Actualizando " + serie[0])
item = Item(url=serie[1], show=serie[0], extra=serie[3])
try:
itemlist = []
pathchannels = os.path.join(config.get_runtime_path(), 'channels', serie[2].strip() + '.py')
logger.info("streamondemand.library_service Cargando canal " + pathchannels + " " + serie[2].strip())
obj = imp.load_source(serie[2].strip(), pathchannels)
itemlist = obj.episodios(item)
except:
import traceback
logger.error(traceback.format_exc())
itemlist = []
else:
logger.info(
"streamondemand.library_service No actualiza " + serie[0] + " (no existe el directorio)")
itemlist = []
for item in itemlist:
try:
item.show = serie[0].strip()
library.savelibrary(titulo=item.title, url=item.url, thumbnail=item.thumbnail,
server=item.server, plot=item.plot, canal=item.channel,
category="Series", Serie=item.show.strip(), verbose=False,
accion="play_from_library", pedirnombre=False, subtitle=item.subtitle,
extra=item.extra)
except:
logger.info("streamondemand.library_service Capitulo no valido")
import xbmc
xbmc.executebuiltin('UpdateLibrary(video)')
else:
logger.info("No actualiza la biblioteca, está desactivado en la configuración de streamondemand")
except:
logger.info("streamondemand.library_service No hay series para actualizar")