Enigma2 plugin to to play various online streams (mostly Latvian).

CopyFiles.py 1.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. from Components.Task import PythonTask, Task, Job, job_manager
  2. from Tools.Directories import fileExists
  3. from enigma import eTimer
  4. from os import path
  5. class HLSDownloadJob(Job):
  6. def __init__(self, url, destfile, name):
  7. Job.__init__(self, _("HLS download"))
  8. cmdline = '/usr/bin/gst-launch-1.0 "%s" ! hlsdemux ! filesink location="%s"'%(url,destfile)
  9. #cmdline = 'mv -f "%s" "%s"' % (url,destfile)
  10. AddHLSProcessTask(self, cmdline, url, destfile, name)
  11. class AddHLSProcessTask(Task):
  12. def __init__(self, job, cmdline, url, destfile, name):
  13. Task.__init__(self, job, name)
  14. self.setCmdline(cmdline)
  15. self.url = url
  16. self.destfile = destfile
  17. self.ProgressTimer = eTimer()
  18. self.ProgressTimer.callback.append(self.ProgressUpdate)
  19. def ProgressUpdate(self):
  20. if self.srcsize <= 0 or not fileExists(self.destfile, 'r'):
  21. return
  22. self.setProgress(int((path.getsize(self.destfile)/float(self.srcsize))*100))
  23. self.ProgressTimer.start(5000, True)
  24. def prepare(self):
  25. #if fileExists(self.url, 'r'):
  26. self.srcsize = 0 #path.getsize(self.url)
  27. self.ProgressTimer.start(5000, True)
  28. def afterRun(self):
  29. self.setProgress(100)
  30. self.ProgressTimer.stop()