Skip to content

Commit 3abc489

Browse files
committed
Update to version 1.7.0
Thanks to @popking159
1 parent 160e5d3 commit 3abc489

36 files changed

+2725
-328
lines changed

configure.ac

+5
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ AC_CONFIG_FILES([
1010
Makefile
1111
plugin/Makefile
1212
plugin/seekers/Makefile
13+
plugin/seekers/PrijevodiOnline/Makefile
14+
plugin/seekers/Novalermora/Makefile
1315
plugin/seekers/Edna/Makefile
1416
plugin/seekers/Elsubtitle/Makefile
1517
plugin/seekers/Indexsubtitle/Makefile
@@ -19,10 +21,13 @@ plugin/seekers/Moviesubtitles2/Makefile
1921
plugin/seekers/MySubs/Makefile
2022
plugin/seekers/OpenSubtitles/Makefile
2123
plugin/seekers/OpenSubtitles2/Makefile
24+
plugin/seekers/OpenSubtitlesMora/Makefile
2225
plugin/seekers/Podnapisi/Makefile
2326
plugin/seekers/SerialZone/Makefile
2427
plugin/seekers/Subdl/Makefile
2528
plugin/seekers/Subscene/Makefile
29+
plugin/seekers/Subscenebest/Makefile
30+
plugin/seekers/Subssource/Makefile
2631
plugin/seekers/SubtitlesGR/Makefile
2732
plugin/seekers/Subsyts/Makefile
2833
plugin/seekers/Subtitlecat/Makefile

plugin/__init__.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# -*- coding: utf-8 -*-
22
__author__ = "mx3L"
33
__email__ = "[email protected]"
4-
__copyright__ = 'Copyright (c) 2014-2023 mx3L, jbleyel'
4+
__copyright__ = 'Copyright (c) 2014-2025 mx3L, jbleyel, popking159'
55
__license__ = "GPL-v2"
6-
__version__ = "1.5.9"
6+
__version__ = "1.7.0-r12"
77

88
from gettext import bindtextdomain, dgettext, gettext, textdomain
99
from os.path import dirname, join

plugin/e2_utils.py

+1
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ def updateLanguageList(self):
165165
("Frysk", "fy", "NL"),
166166
("Hebrew", "he", "IL"),
167167
("Hrvatski", "hr", "HR"),
168+
("Bosanski", "bs", "BS"),
168169
("Magyar", "hu", "HU"),
169170
("Íslenska", "is", "IS"),
170171
("Italiano", "it", "IT"),

plugin/parsers/baseparser.py

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
from re import sub
2+
3+
14
class ParseError(Exception):
25
pass
36

@@ -76,6 +79,7 @@ def parse(self, text, fps=None):
7679
"""
7780
text = text.strip()
7881
text = text.replace('\x00', '')
82+
text = sub(u'[\u064e\u064f\u0650\u0651\u0652\u064c\u064b\u064d\u0640\ufc62]', '', text)
7983
sublist = self._parse(text, fps)
8084
if len(sublist) <= 1:
8185
raise NoSubtitlesParseError()

plugin/seek.py

+30-16
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
from __future__ import absolute_import
2020
import os
21+
from re import sub
2122
import shutil
2223
import socket
2324
import threading
@@ -27,44 +28,50 @@
2728

2829
try:
2930
from .seekers import SubtitlesDownloadError, SubtitlesSearchError, \
30-
SubtitlesErrors, TitulkyComSeeker, EdnaSeeker, SerialZoneSeeker, ElsubtitleSeeker, IndexsubtitleSeeker, MoviesubtitlesSeeker, Moviesubtitles2Seeker, MySubsSeeker, \
31-
OpenSubtitlesSeeker, PodnapisiSeeker, SubsceneSeeker, SubdlSeeker, SubsytsSeeker, SubtitlecatSeeker, SubtitlesGRSeeker, SubtitlesmoraSeeker, SubtitlistSeeker, \
32-
ItasaSeeker, TitloviSeeker
31+
SubtitlesErrors, SubtitlesmoraSeeker, NovalermoraSeeker,TitulkyComSeeker, EdnaSeeker, SerialZoneSeeker, ElsubtitleSeeker, IndexsubtitleSeeker, MoviesubtitlesSeeker, Moviesubtitles2Seeker, MySubsSeeker, \
32+
OpenSubtitlesSeeker, PodnapisiSeeker, SubsceneSeeker, SubdlSeeker, SubsytsSeeker, SubtitlecatSeeker, SubtitlesGRSeeker, SubtitlistSeeker, \
33+
ItasaSeeker, TitloviSeeker, OpenSubtitlesMoraSeeker, PrijevodiOnlineSeeker, SubscenebestSeeker
3334
from .seekers.seeker import BaseSeeker
3435
from .seekers.utilities import languageTranslate, langToCountry, \
3536
getCompressedFileType, detectSearchParams
3637
from .utils import SimpleLogger, toString
3738
except (ValueError, ImportError):
3839
from seekers import SubtitlesDownloadError, SubtitlesSearchError, \
39-
SubtitlesErrors, TitulkyComSeeker, EdnaSeeker, SerialZoneSeeker, ElsubtitleSeeker, IndexsubtitleSeeker, MoviesubtitlesSeeker, Moviesubtitles2Seeker, MySubsSeeker, \
40-
OpenSubtitlesSeeker, PodnapisiSeeker, SubsceneSeeker, SubdlSeeker, SubsytsSeeker, SubtitlecatSeeker, SubtitlesGRSeeker, SubtitlesmoraSeeker, SubtitlistSeeker, \
41-
ItasaSeeker, TitloviSeeker
40+
SubtitlesErrors, SubtitlesmoraSeeker, NovalermoraSeeker,TitulkyComSeeker, EdnaSeeker, SerialZoneSeeker, ElsubtitleSeeker, IndexsubtitleSeeker, MoviesubtitlesSeeker, Moviesubtitles2Seeker, MySubsSeeker, \
41+
OpenSubtitlesSeeker, PodnapisiSeeker, SubsceneSeeker, SubdlSeeker, SubsytsSeeker, SubtitlecatSeeker, SubtitlesGRSeeker, SubtitlistSeeker, \
42+
ItasaSeeker, TitloviSeeker, OpenSubtitlesMoraSeeker, PrijevodiOnlineSeeker, SubscenebestSeeker
4243
from seekers.seeker import BaseSeeker
4344
from seekers.utilities import languageTranslate, langToCountry, \
4445
getCompressedFileType, detectSearchParams
4546
from utils import SimpleLogger, toString
4647

4748

4849
SUBTITLES_SEEKERS = []
49-
SUBTITLES_SEEKERS.append(TitulkyComSeeker)
50-
SUBTITLES_SEEKERS.append(EdnaSeeker)
51-
SUBTITLES_SEEKERS.append(SerialZoneSeeker)
52-
SUBTITLES_SEEKERS.append(ElsubtitleSeeker)
53-
SUBTITLES_SEEKERS.append(IndexsubtitleSeeker)
54-
SUBTITLES_SEEKERS.append(MoviesubtitlesSeeker)
55-
SUBTITLES_SEEKERS.append(Moviesubtitles2Seeker)
56-
SUBTITLES_SEEKERS.append(MySubsSeeker)
50+
SUBTITLES_SEEKERS.append(NovalermoraSeeker)
51+
SUBTITLES_SEEKERS.append(SubtitlesmoraSeeker)
52+
SUBTITLES_SEEKERS.append(SubscenebestSeeker)
5753
SUBTITLES_SEEKERS.append(OpenSubtitlesSeeker)
54+
SUBTITLES_SEEKERS.append(OpenSubtitlesMoraSeeker)
55+
SUBTITLES_SEEKERS.append(MySubsSeeker)
56+
SUBTITLES_SEEKERS.append(SubsourceSeeker)
57+
SUBTITLES_SEEKERS.append(OpenSubtitles2Seeker)
5858
SUBTITLES_SEEKERS.append(SubdlSeeker)
59+
SUBTITLES_SEEKERS.append(ElsubtitleSeeker)
60+
SUBTITLES_SEEKERS.append(TitulkyComSeeker)
61+
#SUBTITLES_SEEKERS.append(PodnapisiSeeker)
5962
SUBTITLES_SEEKERS.append(SubsytsSeeker)
6063
SUBTITLES_SEEKERS.append(SubtitlecatSeeker)
6164
SUBTITLES_SEEKERS.append(SubtitlesGRSeeker)
62-
SUBTITLES_SEEKERS.append(SubtitlesmoraSeeker)
6365
SUBTITLES_SEEKERS.append(SubtitlistSeeker)
6466
SUBTITLES_SEEKERS.append(ItasaSeeker)
65-
#SUBTITLES_SEEKERS.append(PodnapisiSeeker)
6667
SUBTITLES_SEEKERS.append(SubsceneSeeker)
6768
SUBTITLES_SEEKERS.append(TitloviSeeker)
69+
SUBTITLES_SEEKERS.append(PrijevodiOnlineSeeker)
70+
SUBTITLES_SEEKERS.append(SerialZoneSeeker)
71+
SUBTITLES_SEEKERS.append(IndexsubtitleSeeker)
72+
SUBTITLES_SEEKERS.append(MoviesubtitlesSeeker)
73+
SUBTITLES_SEEKERS.append(Moviesubtitles2Seeker)
74+
SUBTITLES_SEEKERS.append(EdnaSeeker)
6875

6976

7077
class ErrorSeeker(BaseSeeker):
@@ -245,6 +252,9 @@ def downloadSubtitle(self, selected_subtitle, subtitles_dict, choosefile_cb, pat
245252
if save_as == 'version':
246253
self.log.debug('filename creating by "version" setting')
247254
filename = toString(selected_subtitle['filename'])
255+
# Sanitize the filename to remove slashes and double dots
256+
filename = sub(r'[\\/]', '_', filename) # Replace slashes with underscores
257+
filename = sub(r'\.\.', '.', filename) # Replace double dots with a single dot
248258
if os.path.splitext(filename)[1] not in self.SUBTILES_EXTENSIONS:
249259
filename = os.path.splitext(filename)[0] + ext
250260
elif save_as == 'video':
@@ -266,6 +276,10 @@ def downloadSubtitle(self, selected_subtitle, subtitles_dict, choosefile_cb, pat
266276
self.log.debug('using custom download path: "%s"', path)
267277
download_path = os.path.join(toString(path), filename)
268278
self.log.debug('download path: "%s"', download_path)
279+
280+
# Ensure the destination directory exists
281+
os.makedirs(os.path.dirname(download_path), exist_ok=True)
282+
269283
if os.path.isfile(download_path) and overwrite_cb is not None:
270284
ret = overwrite_cb(download_path)
271285
if ret is None:
+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
installdir = $(libdir)/enigma2/python/Plugins/Extensions/SubsSupport/seekers/Novalermora
2+
install_PYTHON = __init__.py service.py
3+
install_DATA = logo.png
4+
+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from __future__ import absolute_import
2+
# Dummy file to make this directory a package.
3+
from . import service as novalermora

plugin/seekers/Novalermora/logo.png

13.3 KB
Loading

plugin/seekers/Novalermora/service.py

+216
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,216 @@
1+
# -*- coding: UTF-8 -*-
2+
from __future__ import absolute_import
3+
from __future__ import print_function
4+
5+
import sys
6+
import difflib
7+
from six.moves import html_parser
8+
from six.moves.urllib.parse import quote_plus, urlencode
9+
import urllib.request
10+
import urllib.parse
11+
import html
12+
import urllib3
13+
import requests, json, re, random, string, time, warnings
14+
from requests.packages.urllib3.exceptions import InsecureRequestWarning
15+
warnings.simplefilter('ignore',InsecureRequestWarning)
16+
import os, os.path
17+
from six.moves.urllib.request import HTTPCookieProcessor, build_opener, install_opener, Request, urlopen, FancyURLopener
18+
from six.moves import http_cookiejar
19+
from ..utilities import languageTranslate, log, getFileSize
20+
from urllib import request, parse
21+
from urllib.parse import urlencode
22+
import six
23+
from six.moves import urllib
24+
from six.moves import xmlrpc_client
25+
import calendar
26+
from ..seeker import SubtitlesDownloadError, SubtitlesErrors
27+
28+
PY3 = False
29+
if sys.version_info[0] == 3:
30+
from urllib.request import urlopen, Request
31+
PY3 = True
32+
else:
33+
from urllib2 import urlopen, Request
34+
from urllib3 import urlopen, Request
35+
36+
37+
if sys.version_info[0] == 3:
38+
from urllib.parse import quote # Python 3
39+
else:
40+
from urllib import quote # Python 2
41+
from urllib3 import quote
42+
43+
44+
try:
45+
from urllib import unquote
46+
except ImportError:
47+
from urllib.parse import unquote
48+
49+
HDR= {'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; rv:109.0) Gecko/20100101 Firefox/115.0',
50+
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8',
51+
'Accept-Language': 'fr,fr-FR;q=0.8,en-US;q=0.5,en;q=0.3',
52+
'Content-Type': 'text/html; charset=UTF-8',
53+
'Host': 'subs.ath.cx',
54+
'Referer': 'http://subs.ath.cx',
55+
'Upgrade-Insecure-Requests': '1',
56+
'Connection': 'keep-alive',
57+
'Accept-Encoding':'gzip, deflate'}#, deflate'}
58+
59+
s = requests.Session()
60+
61+
main_url = "http://subs.ath.cx"
62+
debug_pretext = "subs.ath.cx"
63+
64+
65+
def get_url(url, referer=None):
66+
if referer is None:
67+
headers = {'User-agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:6.0) Gecko/20100101 Firefox/6.0'}
68+
else:
69+
headers = {'User-agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:6.0) Gecko/20100101 Firefox/6.0', 'Referer': referer}
70+
req = urllib.request.Request(url, None, headers)
71+
response = urllib.request.urlopen(req)
72+
content = response.read().decode('utf-8')
73+
response.close()
74+
content = content.replace('\n', '')
75+
return content
76+
77+
78+
def get_rating(downloads):
79+
rating = int(downloads)
80+
if (rating < 50):
81+
rating = 1
82+
elif (rating >= 50 and rating < 100):
83+
rating = 2
84+
elif (rating >= 100 and rating < 150):
85+
rating = 3
86+
elif (rating >= 150 and rating < 200):
87+
rating = 4
88+
elif (rating >= 200 and rating < 250):
89+
rating = 5
90+
elif (rating >= 250 and rating < 300):
91+
rating = 6
92+
elif (rating >= 300 and rating < 350):
93+
rating = 7
94+
elif (rating >= 350 and rating < 400):
95+
rating = 8
96+
elif (rating >= 400 and rating < 450):
97+
rating = 9
98+
elif (rating >= 450):
99+
rating = 10
100+
return rating
101+
102+
103+
def search_subtitles(file_original_path, title, tvshow, year, season, episode, set_temp, rar, lang1, lang2, lang3, stack): #standard input
104+
subtitles_list = []
105+
msg = ""
106+
title = str(title).replace(':', '').replace(' ', ' ').replace(',', '').replace("'", "").replace("&", "and").replace("!", "").replace("?", "").replace("- ", "").replace(" III", " 3").replace(" II", " 2").title()
107+
if len(tvshow) == 0 and year: # Movie
108+
searchstring = "%s (%s)" % (title, year)
109+
elif len(tvshow) > 0 and title == tvshow: # Movie not in Library
110+
searchstring = "%s (%#02d%#02d)" % (tvshow, int(season), int(episode))
111+
elif len(tvshow) > 0: # TVShow
112+
searchstring = "%s S%#02dE%#02d" % (tvshow, int(season), int(episode))
113+
else:
114+
searchstring = title
115+
log(__name__, "%s Search string = %s" % (debug_pretext, searchstring))
116+
get_subtitles_list(title, searchstring, "ar", "Arabic", subtitles_list)
117+
return subtitles_list, "", msg #standard output
118+
119+
120+
def download_subtitles(subtitles_list, pos, zip_subs, tmp_sub_dir, sub_folder, session_id): #standard input
121+
language = subtitles_list[pos]["language_name"]
122+
id = subtitles_list[pos]["id"]
123+
#id = re.compile('(.+?.+?)/').findall(id)[-1]
124+
downloadlink = 'http://subs.ath.cx/subtitles/%s' % (id)
125+
#id = 'http://www.findsubtitles.eu/getp.php?id=%s' % (id)
126+
print(downloadlink)
127+
if downloadlink:
128+
log(__name__ , "%s Downloadlink: %s " % (debug_pretext, downloadlink))
129+
viewstate = 0
130+
previouspage = 0
131+
subtitleid = 0
132+
typeid = "zip"
133+
filmid = 0
134+
postparams = { '__EVENTTARGET': 's$lc$bcr$downloadLink', '__EVENTARGUMENT': '' , '__VIEWSTATE': viewstate, '__PREVIOUSPAGE': previouspage, 'subtitleId': subtitleid, 'typeId': typeid, 'filmId': filmid}
135+
#postparams = urllib3.request.urlencode({ '__EVENTTARGET': 's$lc$bcr$downloadLink', '__EVENTARGUMENT': '' , '__VIEWSTATE': viewstate, '__PREVIOUSPAGE': previouspage, 'subtitleId': subtitleid, 'typeId': typeid, 'filmId': filmid})
136+
#class MyOpener(urllib.FancyURLopener):
137+
#version = 'User-Agent=Mozilla/5.0 (Windows NT 6.1; rv:109.0) Gecko/20100101 Firefox/115.0'
138+
#my_urlopener = MyOpener()
139+
#my_urlopener.addheader('Referer', url)
140+
log(__name__ , "%s Fetching subtitles using url with referer header '%s' and post parameters '%s'" % (debug_pretext, downloadlink, postparams))
141+
#response = my_urlopener.open(downloadlink, postparams)
142+
response = s.get(downloadlink,data=postparams,headers=HDR,verify=False,allow_redirects=True)
143+
print(response.content)
144+
local_tmp_file = zip_subs
145+
try:
146+
log(__name__ , "%s Saving subtitles to '%s'" % (debug_pretext, local_tmp_file))
147+
if not os.path.exists(tmp_sub_dir):
148+
os.makedirs(tmp_sub_dir)
149+
local_file_handle = open(local_tmp_file, 'wb')
150+
local_file_handle.write(response.content)
151+
local_file_handle.close()
152+
# Check archive type (rar/zip/else) through the file header (rar=Rar!, zip=PK) urllib3.request.urlencode
153+
myfile = open(local_tmp_file, "rb")
154+
myfile.seek(0)
155+
if (myfile.read(1).decode('utf-8') == 'R'):
156+
typeid = "rar"
157+
packed = True
158+
log(__name__ , "Discovered RAR Archive")
159+
else:
160+
myfile.seek(0)
161+
if (myfile.read(1).decode('utf-8') == 'P'):
162+
typeid = "zip"
163+
packed = True
164+
log(__name__ , "Discovered ZIP Archive")
165+
else:
166+
typeid = "srt"
167+
packed = False
168+
subs_file = local_tmp_file
169+
log(__name__ , "Discovered a non-archive file")
170+
myfile.close()
171+
log(__name__ , "%s Saving to %s" % (debug_pretext, local_tmp_file))
172+
except:
173+
log(__name__ , "%s Failed to save subtitle to %s" % (debug_pretext, local_tmp_file))
174+
if packed:
175+
subs_file = typeid
176+
log(__name__ , "%s Subtitles saved to '%s'" % (debug_pretext, local_tmp_file))
177+
return packed, language, subs_file # standard output
178+
179+
def get_subtitles_list(title, searchstring, languageshort, languagelong, subtitles_list):
180+
url = '%s/subtitles' % (main_url)
181+
title = title.strip()
182+
183+
#url = 'https://archive.org/download/iptvworld-1/A/' quote_plus(title)
184+
d = quote_plus(title)
185+
d = d.replace('+', '.')
186+
print('url', url)
187+
print('d', d)
188+
print('searchstring', searchstring)
189+
try:
190+
log(__name__, "%s Getting url: %s" % (debug_pretext, url))
191+
content = s.get(url,headers=HDR,verify=False,allow_redirects=True).text
192+
#print(content)
193+
except:
194+
pass
195+
log(__name__, "%s Failed to get url:%s" % (debug_pretext, url))
196+
return
197+
try:
198+
log( __name__ ,"%s Getting '%s' subs ..." % (debug_pretext, languageshort))
199+
subtitles = re.compile(r'(<td><a href.+?">'+d+'.+?</a></td>)', re.IGNORECASE).findall(content)
200+
#print(subtitles)
201+
except:
202+
log( __name__ ,"%s Failed to get subtitles" % (debug_pretext))
203+
return
204+
for subtitle in subtitles:
205+
try:
206+
filename = re.compile('<td><a href=".+?">(.+?)</a></td>').findall(subtitle)[0]
207+
filename = filename.strip().replace('.srt', '')
208+
#print(filename)
209+
id = re.compile('href="(.+?)"').findall(subtitle)[0]
210+
#print(id)
211+
if not (filename == 'Εργαστήρι Υποτίτλων' or filename == 'subs4series'):
212+
log( __name__ ,"%s Subtitles found: %s (id = %s)" % (debug_pretext, filename, id))
213+
subtitles_list.append({'no_files': 1, 'filename': filename, 'sync': True, 'id' : id, 'language_flag': 'flags/' + languageshort + '.gif', 'language_name': languagelong})
214+
except:
215+
pass
216+
return

0 commit comments

Comments
 (0)