Skip to content

Commit

Permalink
filename regex amends, vod downloader amends
Browse files Browse the repository at this point in the history
  • Loading branch information
kiddac committed Jan 10, 2025
1 parent 973f939 commit 8772ae4
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 42 deletions.
2 changes: 1 addition & 1 deletion CONTROL/control
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Package: enigma2-plugin-extensions-xklass
Version: 1.30-20241223
Version: 1.32-20250110
Section: misc
Priority: optional
Architecture: all
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,15 +254,15 @@ def diskspace(self):

def cleanalltitles(self):
if debugs:
print("*** clean titles ***")
print("*** cleanalltitles ***")
for video in self.downloads_all:
video[1] = self.cleantitle(video[1])

def getDownloadSize(self):
if debugs:
print("*** getDownloadSize ***")
x = 0
for idx, video in enumerate(self.downloads_all):
for video in self.downloads_all:

if video[5] == 0:
url = video[2]
Expand All @@ -276,11 +276,9 @@ def getDownloadSize(self):

try:
r = http.get(url, headers=hdr, timeout=20, verify=False, stream=True)

r.raise_for_status()

if r.status_code == requests.codes.ok or r.status_code == 206:

content_length = r.headers.get("content-length")

if content_length:
Expand All @@ -298,17 +296,19 @@ def getDownloadSize(self):

video[5] = content_length

if video[3] == "Error":
video[3] = "Not Started"
if content_length:
if video[3] == "Error":
video[3] = "Not Started"
else:
video[3] = "Error"

else:
video[3] = "Error"

except Exception:
except Exception as e:
print(e)
video[5] = 0
video[3] = "Error"
else:
pass

x += 1
if x == 5:
Expand Down Expand Up @@ -340,17 +340,20 @@ def checkactivedownloads(self):
if int(totalbytes) != int(recbytes):
try:
video[4] = int((float(recbytes) / float(totalbytes)) * 100) - 2
except:
except Exception as e:
print(e)
video[4] = 0

if video[4] < 0:
video[4] = 0
if video[3] == "Downloaded":
video[4] = 100
"""
else:
print("*** video not exist ***")
if video[3] != "Not Started":
continue

"""
templist.append(video)

self.downloads_all[:] = templist
Expand All @@ -360,11 +363,8 @@ def checkactivedownloads(self):
def stopDownloads(self):
if debugs:
print("*** stopDownloads ***")
# stop all active tasks
for job in JobManager.getPendingJobs():

if "XKlass" in job.cmdline:

if job.status == job.NOT_STARTED:
JobManager.active_jobs.remove(job)

Expand All @@ -376,8 +376,6 @@ def stopDownloads(self):
def resumeDownloads(self):
if debugs:
print("*** resumeDownloads ***")
started_download = False

for video in self.downloads_all:
filmtitle = str(video[1])
url = str(video[2])
Expand All @@ -396,8 +394,6 @@ def resumeDownloads(self):
video_domain = parsed_uri.hostname

if state == "In progress" or state == "Waiting":
started_download = True

if self.session.nav.getCurrentlyPlayingServiceReference():
playingstream = self.session.nav.getCurrentlyPlayingServiceReference().toString()

Expand All @@ -417,14 +413,6 @@ def resumeDownloads(self):

break

if not started_download:
for index, video in enumerate(self.downloads_all):
if video[3] == "Not Started":
self["downloadlist"].setIndex(index)

self.download()
break

self.updatescreen()

def fail(self, job=None, task=None, problems=None):
Expand Down Expand Up @@ -568,30 +556,31 @@ def cancelConfirm(self, answer=None):
def cancelJob(self, answer=None):
if debugs:
print("*** canceljobs ***")

for video in self.downloads_all:
if str(video[1]) == str(self.filmtitle):
video[3] = "Not Started"
self.buildList()
self.saveJson()

jobs = JobManager.getPendingJobs()

for job in jobs:
jobname = str(job.name)
if self.filmtitle == jobname:

for video in self.downloads_all:
if str(video[1]) == str(self.filmtitle):
video[3] = "Not Started"
self.buildList()
self.saveJson()

if job.status == job.NOT_STARTED:
JobManager.active_jobs.remove(job)
if job.status == job.NOT_STARTED:
JobManager.active_jobs.remove(job)

elif job.status == job.IN_PROGRESS:
job.cancel()
elif job.status == job.IN_PROGRESS:
job.cancel()

def delete(self):
if debugs:
print("*** delete ***")
if self["downloadlist"].getCurrent():
currentindex = self["downloadlist"].getIndex()
if self.downloads_all[currentindex][3] == _("In progress") or self.downloads_all[currentindex][3] == _("Waiting"):
if self.downloads_all[currentindex][3] == "In progress" or self.downloads_all[currentindex][3] == "Waiting":
return
else:
self.delete_entry()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -740,7 +740,7 @@ def downloadApiData(self, url):

def xmltvCheckData(self):
# print("*** xmltvCheckData ***")
safeName = re.sub(r'[\<\>\:\"\/\\\|\?\*]', "_", str(glob.active_playlist["playlist_info"]["name"]))
safeName = re.sub(r'[\'\<\>\:\"\/\\\|\?\*\(\)\[\]]', "_", str(glob.active_playlist["playlist_info"]["name"]))
safeName = re.sub(r" +", "_", safeName) # Combine multiple spaces into one underscore
safeName = re.sub(r"_+", "_", safeName) # Replace multiple underscores with a single underscore

Expand Down Expand Up @@ -1767,7 +1767,7 @@ def downloadComplete(self, data=None, filename=None):

def buildXMLTV(self):
# print("*** buildxmltv ***")
safeName = re.sub(r'[\<\>\:\"\/\\\|\?\*]', "_", str(glob.active_playlist["playlist_info"]["name"]))
safeName = re.sub(r'[\'\<\>\:\"\/\\\|\?\*\(\)\[\]]', "_", str(glob.active_playlist["playlist_info"]["name"]))
safeName = re.sub(r" +", "_", safeName)
safeName = re.sub(r"_+", "_", safeName)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ def epgimportcleanup(self):
self.playlists_all = []

for playlist in self.playlists_all:
cleanName = re.sub(r'[\<\>\:\"\/\\\|\?\*]', "_", str(playlist["playlist_info"]["name"]))
cleanName = re.sub(r'[\'\<\>\:\"\/\\\|\?\*\(\)\[\]]', "_", str(playlist["playlist_info"]["name"]))
cleanName = re.sub(r" +", "_", cleanName)
cleanName = re.sub(r"_+", "_", cleanName)
channelfilelist.append(cleanName)
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.30-20241223
1.32-20250110

0 comments on commit 8772ae4

Please sign in to comment.