-
Notifications
You must be signed in to change notification settings - Fork 20
/
library_service.py
105 lines (89 loc) · 4.32 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
# -*- coding: utf-8 -*-
#------------------------------------------------------------
# pelisalacarta 4
# Copyright 2015 [email protected]
#
# 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 pelisalacarta 4.
#
# pelisalacarta 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.
#
# pelisalacarta 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 pelisalacarta 4. If not, see <http://www.gnu.org/licenses/>.
#------------------------------------------------------------
# Service for updating new episodes on library series
#------------------------------------------------------------
# -- Update servertools and servers from repository pelisalacarta.italiano ------
try:
from core import update_servers
except:
logger.info("streamondemand.library_service Error en update_servers")
# ----------------------------------------------------------------------
import urlparse,urllib2,urllib,re
import os
import sys
import xbmc,time
from core import scrapertools
from core import config
from core import logger
from core.item import Item
from servers import servertools
logger.info("streamondemand.library_service Actualizando series...")
from platformcode import library
from platformcode import launcher
import xbmcgui
import imp
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])
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:
#logger.info("item="+item.tostring())
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 , verbose=False, accion="play_from_library", pedirnombre=False, subtitle=item.subtitle )
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")