rename SubsDownloader2 to subsdownloader2 to fix packaging
[enigma2-plugins.git] / subsdownloader2 / src / SourceCode / xbmc_subtitles / XBMC_search.py
1 #from XBMC.utilities import *\r
2 #from periscope.plugins.SubtitleDatabase import SubtitleDB\r
3 #from Plugins.Extensions.SubsDownloader2.SourceCode.periscope.SubtitleDatabase import SubtitleDB, tvshowRegex, tvshowRegex2, movieRegex\r
4 import os\r
5 #from XBMC.archives_extractor import zip_extractor\r
6 #from Plugins.Extensions.SubsDownloader2.SourceCode.archives_extractor import zip_extractor\r
7 \r
8 def list_XBMC_Periscope_plugins(XBMC_periscope_plugin_path):\r
9     plugin_list = []\r
10     for x in os.listdir(XBMC_periscope_plugin_path):\r
11         if os.path.isdir(XBMC_periscope_plugin_path+x) == True:\r
12             plugin_list.append(x)    \r
13     return plugin_list\r
14 \r
15 """\r
16 def list_directory_files(dir_path):\r
17     file_list = []\r
18     for x in os.listdir(dir_path):\r
19         if os.path.isdir(XMBC_plugin_path+x) == False:\r
20             file_list.append(dir_path+x)    \r
21     return file_list"""\r
22 """\r
23 def new_file_in_directory(files_before, files_after):\r
24     new_file = []\r
25     for x in files_after:\r
26         if x in files_before:\r
27             pass\r
28         else:\r
29             new_file.append(x)\r
30     return new_file"""\r
31             \r
32 #XBMCSubtitle not USED\r
33 """\r
34 class XBMCSubtitle(SubtitleDB):\r
35     def __init__(self,service):\r
36         self.tvshowRegex = tvshowRegex\r
37         self.tvshowRegex2 = tvshowRegex2\r
38         self.movieRegex = movieRegex\r
39         \r
40         exec ('from Plugins.Extensions.SubsDownloader2.SourceCode.xbmc_subtitles.services.%s import *' % service)\r
41         exec ('from Plugins.Extensions.SubsDownloader2.SourceCode.xbmc_subtitles.services.%s import service as Service' % service)        \r
42         self.service = Service\r
43 \r
44     \r
45     def XBMC_search_subtitles(self, file_path, lang1, lang2,lang3, year = None, set_temp = False, rar = False, stock = True):\r
46         self.file_path = file_path\r
47         self.__subtitle_list = []\r
48         self.__session_id = None\r
49         self.__msg = None        \r
50         fileData = self.guessFileData(self.file_path)\r
51         #===============================================================================\r
52         # Public interface functions\r
53         #===============================================================================\r
54         \r
55         # This function is called when the service is selected through the subtitles\r
56         # addon OSD.\r
57         # file_original_path -> Original system path of the file playing\r
58         # title -> Title of the movie or episode name\r
59         # tvshow -> Name of a tv show. Empty if video isn't a tv show (as are season and\r
60         #           episode)\r
61         # year -> Year\r
62         # season -> Season number\r
63         # episode -> Episode number\r
64         # set_temp -> True iff video is http:// stream\r
65         # rar -> True iff video is inside a rar archive\r
66         # lang1, lang2, lang3 -> Languages selected by the user\r
67         #return self..search_subtitles(self.file_path,fileData['name'],fileData['type'], year, fileData['season'],fileData['episode'],set_temp,rar, lang1, lang2, lang3, 1)\r
68         if fileData['type'] == 'tvshow':\r
69             tvShow = fileData['name']\r
70             season = fileData['season']\r
71             episode = fileData['episode']\r
72             #print fileData\r
73         elif fileData['type'] =='movie' or fileData['type'] =='unknown':\r
74             tvShow = []\r
75             season = []\r
76             episode = []  \r
77             #print fileData\r
78         self.__subtitles_list, self.__session_id, self.__msg = self.service.search_subtitles(file_path, fileData['name'], tvShow, year, season, episode, set_temp, rar, lang1, lang2, lang3, stock)\r
79         return self.__subtitles_list\r
80     \r
81     def XBMC_download_subtitles(self, pos):\r
82         tmp_sub_dir = sub_folder = self.file_path.rsplit("/",1)[0]\r
83         zipped_subs_path = self.file_path.rsplit(".",1)[0]+".zip"\r
84         session_id = self.__session_id\r
85         subtitles_list = self.__subtitles_list\r
86         return self.service.download_subtitles (subtitles_list, pos, zipped_subs_path, tmp_sub_dir, sub_folder, session_id) #ZWRAA False, language, subs_file #standard output\r
87 """\r