Skip to content

Commit

Permalink
add External subtitles (#4175)
Browse files Browse the repository at this point in the history
-[InfoBar] search for srt/ass/ssa file next to the movie file and use
the first found as external subtitle
-[iservice] add setSubUri
  • Loading branch information
Dima73 authored Jan 26, 2025
1 parent 0117bdf commit 6d36942
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
14 changes: 13 additions & 1 deletion lib/python/Screens/InfoBar.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from Tools.Profile import profile
from enigma import eServiceReference
import os
from glob import glob
from os.path import splitext

# workaround for required config entry dependencies.
import Screens.MovieSelection
Expand Down Expand Up @@ -202,6 +203,17 @@ def __init__(self, session, service, slist=None, lastservice=None, infobar=None)
self.servicelist = slist
self.infobar = infobar
self.lastservice = lastservice or session.nav.getCurrentlyPlayingServiceOrGroup()

path = service and service.getPath() and splitext(service.getPath())[0] or ""
subs = []
if path:
for sub in ("srt", "ass", "ssa"):
subs = glob("%s*.%s" % (path, sub))
if subs:
break
if subs:
service.setSubUri(subs[0]) # Support currently only one external sub

session.nav.playService(service)
self.cur_service = service
self.returning = False
Expand Down
2 changes: 2 additions & 0 deletions lib/service/iservice.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,11 @@ class eServiceReference
#ifndef SWIG
int data[8];
std::string path;
std::string suburi;
#endif
std::string getPath() const { return path; }
void setPath( const std::string &n ) { path=n; }
void setSubUri( const std::string &n ) { suburi=n; }

unsigned int getUnsignedData(unsigned int num) const
{
Expand Down

1 comment on commit 6d36942

@Dima73
Copy link
Contributor Author

@Dima73 Dima73 commented on 6d36942 Jan 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @jbleyel

Please sign in to comment.