Skip to content

Commit

Permalink
New Subtitle handler registration mode, small fixes and corrections
Browse files Browse the repository at this point in the history
  • Loading branch information
murbaniak committed May 25, 2012
1 parent 07af82a commit 37f4cd5
Show file tree
Hide file tree
Showing 17 changed files with 452 additions and 519 deletions.
113 changes: 47 additions & 66 deletions Docs/plugins/subtitles.txt
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -5,93 +5,74 @@ Plugin video.subtitles provides framework that allows individual
plugins or handlers as I'd like to call them to download subtitles from plugins or handlers as I'd like to call them to download subtitles from
(currently) the follwoing sites: (currently) the follwoing sites:


http://napiprojekt.pl http://napiprojekt.pl
http://opensubtitles.org http://opensubtitles.org
Subtitles plugin on it's own does not know how to download the sobtitles Subtitles plugin on it's own does not know how to download the sobtitles
from these sites. It needs at least one specialised handler (napiprojekt from these sites. It needs at least one specialised handler (napiprojekt
or opensubtitles) registered for the download to work. or opensubtitles) registered for the download to work.


To enable the plugin and the handlers all one needs to do is to insert To enable the plugin and the handlers all one needs to do is to insert
following lines into the local_config.py as a bare minimum: following lines into the local_config.py:


plugin.activate('video.subtitles') plugin.activate('video.subtitles')
SUBS_HANDLERS = ['video.napiprojekt', 'video.opensubtitles', ] plugin.activate('video.subtitles.napiprojekt')

plugin.activate('video.subtitles.opensubtitles')
The specialised plugins can be activated explicitly within the local_config.py
but this is not necessary. Main Subtitles plugin will activate the plugins it
found from the entries in the SUBS_HANDLERS variable.


Each handler knows how to get a list available subtitles, download, Each handler knows how to get a list available subtitles, download,
decompress and save subtitles. decompress and save subtitles.


By default the plugin support following subtitle langauges: By default the plugin support following subtitle langauges:


English English
German
Polish

NOTE: napirojekt only supports 2 languages, Polish and English!!!

BTW; Subtitles plugin works with ISO 639-2 language codes.
Vist http://en.wikipedia.org/wiki/List_of_ISO_639-2_codes for details.


If you want to narrow the list of the subtitles being pulled, declare but it can easly configured to support additional langauges:
the following for example:


SUBS_LANGS = { 'eng': ('English'), 'ger': ('German'), } SUBS_LANGS = { 'eng': ('English'), 'ger': ('German'), }
This will only pull English and German subtitles. in the above dictionary, This will only pull English and German subtitles. in the above dictionary,
key represents the ISO 639-2 language code and value represents key represents the ISO 639-2 language code and value represents
the language name as used by the plugin to display on OSD, menus etc. the language name as used by the plugin to display on OSD, menus etc.


NOTE: napirojekt only supports 2 languages, Polish and English!!!

BTW; Subtitles plugin works with ISO 639-2 language codes.
Vist http://en.wikipedia.org/wiki/List_of_ISO_639-2_codes for details.

User will be presented with the Menu of available Subtitle files in these User will be presented with the Menu of available Subtitle files in these
languages and will be allowed to make a choice which Subs to save to languages and will be allowed to make a choice which Subs to save to
the local filesystem. the local filesystem.


If you are interested only in the English subtitles, then:

SUBS_LANGS = { 'eng': ('English'), }

If you require some other language, that the plugin is not configured with
by default, you'd need to tell the Plugin which language you require
(only opensubtitles handler can be extended but napiprojekt supports only
two languages, Polish and English).

For example:

SUBS_LANGS = { 'eng': ('English'), 'ita': ('Italian'), }

There are some other configuration variables that modify the behaviour There are some other configuration variables that modify the behaviour
of main Subtitles plugin as well as individual handlers (with default values): of main Subtitles plugin as well as individual handlers (with default values):


# Blindly download all subs available, otherwise the # Blindly download all subs available, otherwise the
# menu with available aubtitles will be presented and choice can be made # menu with available aubtitles will be presented and choice can be made
SUBS_AUTOACCEPT = False SUBS_AUTOACCEPT = False


# Override existing subtitle file (if exists) # Override existing subtitle file (if exists)
SUBS_FORCE_UPDATE = True SUBS_FORCE_UPDATE = True


# Backup old file if in update mode above # Backup old file if in update mode above
SUBS_FORCE_BACKUP = True SUBS_FORCE_BACKUP = True


# by default plugin will use follwing filename convention # by default plugin will use follwing filename convention
# xxx.os.eng where os is the handler's ID (os or np) # xxx.os.eng where os is the handler's ID (os or np)
# and eng is the language code of the subtitles. # and eng is the language code of the subtitles.


# Force use of the subtitle lagnguage code in the filename i.e. xxx.eng.txt # Force use of the subtitle lagnguage code in the filename i.e. xxx.eng.txt
SUBS_FORCE_LANG_EXT = True, SUBS_FORCE_LANG_EXT = True,
# Force use of the subtitle handler id in the filename i.e. xxx.os.txt # Force use of the subtitle handler id in the filename i.e. xxx.os.txt
SUBS_FORCE_HANDLER_ID = True, SUBS_FORCE_HANDLER_ID = True,
# opensubtitles user agent and domain # opensubtitles user agent and domain
OSUBS_USER_AGENT = "Freevo v1.9" OSUBS_USER_AGENT = "Freevo v1.9"
OSUBS_DOMAIAN = "http://api.opensubtitles.org/xml-rpc" OSUBS_DOMAIAN = "http://api.opensubtitles.org/xml-rpc"
# napiprojekt URL and zip password # napiprojekt URL and zip password
NAPI_URL = "http://napiprojekt.pl/unit_napisy/dl.php?l=%s&f=%s&t=%s&v=other&kolejka=false&nick=&pass=&napios=%s" NAPI_URL = "http://napiprojekt.pl/unit_napisy/dl.php?l=%s&f=%s&t=%s&v=other&kolejka=false&nick=&pass=&napios=%s"
NAPI_PWD = "iBlm8NTigvru0Jr0" NAPI_PWD = "iBlm8NTigvru0Jr0"




If you define SUBS_FORCE_LANG_EXT or SUBS_FORCE_HANDLER_ID make sure If you define SUBS_FORCE_LANG_EXT or SUBS_FORCE_HANDLER_ID make sure
Expand All @@ -113,11 +94,11 @@ Enjoy!
----- -----
TODO: TODO:
----- -----
# By default opensubtitles handler downloads only one set of subs # By default opensubtitles handler downloads only one set of subs
# for a give movie, the one most often downloaded. Often there are more # for a give movie, the one most often downloaded. Often there are more
# that one set availabe for download, if you want to get a choice of more # that one set availabe for download, if you want to get a choice of more
# that one set, increase the number below (not implemented yet). # that one set, increase the number below (not implemented yet).
OSUBS_MAX_SUBS = 1 OSUBS_MAX_SUBS = 1


------- -------
PS/BTW: PS/BTW:
Expand All @@ -135,6 +116,6 @@ This behaviour is enabled by default and if you do not like it and prefer
mplayer to silently change subs then you can disable it by setting following mplayer to silently change subs then you can disable it by setting following
in your local_config.py: in your local_config.py:


# Prevents freevo from using mplayer's show_ext_prop_text to display # Prevents freevo from using mplayer's show_ext_prop_text to display
# current subs and audio track info on the screen # current subs and audio track info on the screen
MPLAYER_USE_OSD_SHOW_PROPS = True MPLAYER_USE_OSD_SHOW_PROPS = True
5 changes: 3 additions & 2 deletions freevo_config.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -791,8 +791,9 @@


# add subtitle search to the video item menu # add subtitle search to the video item menu
plugin.activate('video.subtitles') plugin.activate('video.subtitles')
SUBS_HANDLERS = [('video.opensubtitles'), ('video.napiprojekt'), ] plugin.activate('video.subtitles.napiprojekt')
SUBS_LANGS = { 'eng': ('English'), } plugin.activate('video.subtitles.opensubtitles')
SUBS_LANGS = { 'eng': ('English') }


# delete file in menu # delete file in menu
plugin.activate('file_ops', level=20) plugin.activate('file_ops', level=20)
Expand Down
3 changes: 2 additions & 1 deletion local_conf.py.example
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -494,7 +494,8 @@ CACHE_IMAGES = 1
# ====================================================================== # ======================================================================
# add subtitle search to the video item menu # add subtitle search to the video item menu
# plugin.activate('video.subtitles') # plugin.activate('video.subtitles')
# SUBS_HANDLERS = [('video.opensubtitles'), ('video.napiprojekt'), ] # plugin.activate('video.subtitles.napiprojekt')
# plugin.activate('video.subtitles.opensubtitles')
# SUBS_LANGS = { 'eng': ('English'), } # SUBS_LANGS = { 'eng': ('English'), }




Expand Down
Binary file added share/images/osd/base/status_bg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added share/images/osd/blurr/status_bg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added share/images/osd/geexbox/status_bg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions share/skins/osd/base.fxd
100755 → 100644
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -132,9 +132,9 @@
<text name="Text1" x="10" y="100" width="480" height="25" expression="progress_text" font="message" align="center" valign="center" fgcolor="white"/> <text name="Text1" x="10" y="100" width="480" height="25" expression="progress_text" font="message" align="center" valign="center" fgcolor="white"/>
<image name="Image1" x="200" y="140" width="100" height="100" expression="indeterminate" scale="aspect" align="left" valign="top" srcexpr="'misc/osd_busy%02d' % (counter % 12)"/> <image name="Image1" x="200" y="140" width="100" height="100" expression="indeterminate" scale="aspect" align="left" valign="top" srcexpr="'misc/osd_busy%02d' % (counter % 12)"/>
</osd> </osd>
<osd name="status" x="25" y="490" width="750" height="40"> <osd name="status" x="200" y="200" width="400" height="200">

This comment has been minimized.

Copy link
@charrea6

charrea6 Jun 2, 2012

Please revert these changes as status is a specific type of message dialog.
Message dialogs don't stop the user interacting with the rest of freevo

<image name="Background" x="0" y="0" width="750" height="40" expression="True" scale="both" align="left" valign="top" src="message_bg.png"/> <image name="Background" x="0" y="0" width="400" height="200" expression="True" scale="both" align="left" valign="top" src="status_bg.png"/>
<text name="Message" x="5" y="0" width="740" height="40" expression="message" font="message" align="left" valign="center"/> <text name="Message" x="5" y="5" width="390" height="190" expression="message" font="message" align="center" valign="center"/>
</osd> </osd>
<osd name="shutdown" x="150" y="200" width="500" height="300"> <osd name="shutdown" x="150" y="200" width="500" height="300">
<image name="background" x="0" y="0" width="500" height="300" expression="True" scale="both" align="left" valign="top" src="dialog_bg.png"/> <image name="background" x="0" y="0" width="500" height="300" expression="True" scale="both" align="left" valign="top" src="dialog_bg.png"/>
Expand Down
12 changes: 6 additions & 6 deletions share/skins/osd/blurr.fxd
100755 → 100644
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
<text name="current_time" x="10" y="563" width="780" height="30" expression="current_time_str" font="menu" align="left" valign="top"/> <text name="current_time" x="10" y="563" width="780" height="30" expression="current_time_str" font="menu" align="left" valign="top"/>
<text name="total_time" x="10" y="563" width="780" height="30" expression="total_time_str" font="menu" align="right" valign="top"/> <text name="total_time" x="10" y="563" width="780" height="30" expression="total_time_str" font="menu" align="right" valign="top"/>
</osd> </osd>
<osd name="message" x="10" y="62" width="780" height="40"> <osd name="message" x="10" y="62" width="780" height="50">
<image name="Background" x="0" y="0" width="780" height="40" expression="True" scale="both" align="left" valign="top" src="message_bg.png"/> <image name="Background" x="0" y="0" width="780" height="50" expression="True" scale="both" align="left" valign="center" src="message_bg.png"/>
<text name="Message" x="5" y="0" width="770" height="40" expression="message" font="message" align="left" valign="center" fgcolor="white"/> <text name="Message" x="5" y="0" width="770" height="40" expression="message" font="message" align="left" valign="center" fgcolor="white"/>
</osd> </osd>
<osd name="1button" x="150" y="200" width="500" height="250"> <osd name="1button" x="150" y="200" width="500" height="250">
Expand Down Expand Up @@ -121,7 +121,7 @@
</widgetstate> </widgetstate>
</widgetstyle> </widgetstyle>
<font label="clock" name="DejaVuSans-Bold" size="16" color="white"/> <font label="clock" name="DejaVuSans-Bold" size="16" color="white"/>
<font label="message" name="DejaVuSans" size="24" color="white"/> <font label="message" name="DejaVuSans" size="20" color="white"/>
<font label="button" name="DejaVuSans" size="12" color="black"/> <font label="button" name="DejaVuSans" size="12" color="black"/>
<font label="button_selected" name="DejaVuSans-Bold" size="14" color="white"/> <font label="button_selected" name="DejaVuSans-Bold" size="14" color="white"/>
<font label="button_pressed" name="DejaVuSans-Bold" size="14" color="black"/> <font label="button_pressed" name="DejaVuSans-Bold" size="14" color="black"/>
Expand All @@ -146,9 +146,9 @@
<text name="Text1" x="10" y="100" width="480" height="25" expression="progress_text" font="message" align="center" valign="center" fgcolor="white"/> <text name="Text1" x="10" y="100" width="480" height="25" expression="progress_text" font="message" align="center" valign="center" fgcolor="white"/>
<image name="Image2" x="200" y="140" width="100" height="100" expression="indeterminate" scale="aspect" align="left" valign="top" srcexpr="'misc/osd_busy%02d' % (counter % 12)"/> <image name="Image2" x="200" y="140" width="100" height="100" expression="indeterminate" scale="aspect" align="left" valign="top" srcexpr="'misc/osd_busy%02d' % (counter % 12)"/>
</osd> </osd>
<osd name="status" x="25" y="490" width="750" height="40"> <osd name="status" x="200" y="200" width="400" height="200">

This comment has been minimized.

Copy link
@charrea6

charrea6 Jun 2, 2012

Please revert

<image name="Background" x="0" y="0" width="750" height="40" expression="True" scale="both" align="left" valign="top" src="message_bg.png"/> <image name="Background" x="0" y="0" width="400" height="200" expression="True" scale="both" align="left" valign="top" src="status_bg.png"/>
<text name="Message" x="5" y="0" width="740" height="40" expression="message" font="message" align="left" valign="center"/> <text name="Message" x="5" y="5" width="390" height="190" expression="message" font="message" align="center" valign="center"/>
</osd> </osd>
<osd name="shutdown" x="150" y="200" width="500" height="300"> <osd name="shutdown" x="150" y="200" width="500" height="300">
<image name="background" x="0" y="0" width="500" height="300" expression="True" scale="both" align="left" valign="top" src="dialog_bg.png"/> <image name="background" x="0" y="0" width="500" height="300" expression="True" scale="both" align="left" valign="top" src="dialog_bg.png"/>
Expand Down
6 changes: 3 additions & 3 deletions share/skins/osd/geexbox.fxd
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -145,9 +145,9 @@
<text name="Text1" x="10" y="100" width="480" height="25" expression="progress_text" font="message" align="center" valign="center" fgcolor="white"/> <text name="Text1" x="10" y="100" width="480" height="25" expression="progress_text" font="message" align="center" valign="center" fgcolor="white"/>
<image name="Image3" x="200" y="140" width="100" height="100" expression="indeterminate" scale="aspect" align="left" valign="top" srcexpr="'misc/osd_busy%02d' % (counter % 12)"/> <image name="Image3" x="200" y="140" width="100" height="100" expression="indeterminate" scale="aspect" align="left" valign="top" srcexpr="'misc/osd_busy%02d' % (counter % 12)"/>
</osd> </osd>
<osd name="status" x="25" y="490" width="750" height="40"> <osd name="status" x="200" y="200" width="400" height="200">

This comment has been minimized.

Copy link
@charrea6

charrea6 Jun 2, 2012

Please revert

<image name="Background" x="0" y="0" width="750" height="40" expression="True" scale="both" align="left" valign="top" src="message_bg.png"/> <image name="Background" x="0" y="0" width="400" height="200" expression="True" scale="both" align="left" valign="top" src="status_bg.png"/>
<text name="Message" x="5" y="0" width="740" height="40" expression="message" font="message" align="left" valign="center"/> <text name="Message" x="5" y="5" width="390" height="190" expression="message" font="message" align="center" valign="center"/>
</osd> </osd>
<osd name="shutdown" x="150" y="200" width="500" height="250"> <osd name="shutdown" x="150" y="200" width="500" height="250">
<image name="background" x="0" y="0" width="500" height="250" expression="True" scale="noscale" align="left" valign="top" src="dialog_bg.png"/> <image name="background" x="0" y="0" width="500" height="250" expression="True" scale="noscale" align="left" valign="top" src="dialog_bg.png"/>
Expand Down
41 changes: 40 additions & 1 deletion src/dialog/utils.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
import os.path import os.path


import config import config

import dialog import dialog
from dialog.dialogs import MessageDialog


def get_xine_config_file(): def get_xine_config_file():
""" """
Expand Down Expand Up @@ -69,3 +69,42 @@ def get_xine_config_file():
outfile.close() outfile.close()


return config_file return config_file


def show_message(message, name='message', duration=None):

This comment has been minimized.

Copy link
@charrea6

charrea6 Jun 2, 2012

You don't need either of these 2 functions. Messages should hide automatically after a time out as they require no interaction from the user.

"""
Helper function that shows the skinnable osd message dialog
@param message: message to be displayed
@param name: name of the dialog used to load appropriate skin object
Default is ’message’, ‘status’ is also available.
See dialog/dialogs.py and osd skin definitions for available
names/dialog types
@param duration: duration the msg is displayed. Default is None which defaults
to the standard duration of the MessageDialog, currently 3 secs
0 will display indefinitely, until hide_message() is called
In this cae caller is responsible for cleaning up, either hide
and finish the dialog or call dialog.util.hide_message()!
@return: instantiated MessageDialog object, needed for subsequent call
to hide_message
"""
dialog = MessageDialog(message)
dialog.name = name
if duration is None:
dialog.show()
else:
dialog.show(duration)

return dialog


def hide_message(dialog):
"""
Helper function that hides and finishes the osd message dialog,
created by show_dialog()
@param dialog: dialog object returned previously by show_dialog()
"""
# check if we have a valid object and check the type too, in case
# someone passed us wrong type, to prevent runtime errors.
if dialog and isinstance(dialog, MessageDialog):
dialog.hide()
dialog.finish()

This comment has been minimized.

Copy link
@charrea6

charrea6 Jun 2, 2012

FYI finish is called by the dialog system to indicate the window has been removed from the stack of dialogs, so shouldn't be called by the user.

3 changes: 2 additions & 1 deletion src/image/viewer.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# ----------------------------------------------------------------------- # -----------------------------------------------------------------------
# Freevo image viewer # Freevo image viewer
# ----------------------------------------------------------------------- # -----------------------------------------------------------------------
# $Id$ # $Id: $
# ----------------------------------------------------------------------- # -----------------------------------------------------------------------
# Freevo - A Home Theater PC framework # Freevo - A Home Theater PC framework
# Copyright (C) 2002 Krister Lagerstrom, et al. # Copyright (C) 2002 Krister Lagerstrom, et al.
Expand Down Expand Up @@ -75,6 +75,7 @@ def get_singleton():
class ImageZoomPosition(): class ImageZoomPosition():
def __init__(self, pos_x = 0, pos_y = 0): def __init__(self, pos_x = 0, pos_y = 0):
""" """
Represents the current position/coordinates within the zoomed in image
""" """
logger.log(9, 'ImageZoomPosition.__init__()') logger.log(9, 'ImageZoomPosition.__init__()')
self.pos_x = pos_x self.pos_x = pos_x
Expand Down
9 changes: 3 additions & 6 deletions src/plugins/archive.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# ----------------------------------------------------------------------- # -----------------------------------------------------------------------
# Freevo Archive file (zip, tar and rar) handling # Freevo Archive file (zip, tar and rar) handling
# ----------------------------------------------------------------------- # -----------------------------------------------------------------------
# $Id$ # $Id: $
# #
# Notes: To use RAR file handling you must install both 'unrar' utility # Notes: To use RAR file handling you must install both 'unrar' utility
# and python rar module. This plugin has been tested with version # and python rar module. This plugin has been tested with version
Expand Down Expand Up @@ -319,11 +319,8 @@ def set_cover_image(self, dir):
return None return None


try: try:
# FIX ME It's more efficient to use symlinks but only on Windows. It's to complicated os.symlink(os.path.join(dir, normalize(image)), os.path.join(dir, ('cover' + ext)))
# to detect the system type and then make a decision if use symlinks or copy (for now) #shutil.copy(os.path.join(dir, normalize(image)), os.path.join(dir, ('cover' + ext)))
# maybe in the future ???
# os.symlink(os.path.join(dir, normalize(image), os.path.join(dir, ('cover' + ext)))
shutil.copy(os.path.join(dir, normalize(image)), os.path.join(dir, ('cover' + ext)))
logger.debug('Cover image %s, copied to %s', normalize(image), dir) logger.debug('Cover image %s, copied to %s', normalize(image), dir)
except (OSError, ShutilError) as exc: except (OSError, ShutilError) as exc:
logger.warning('Error while getting cover image for archive %s, %s', self.archive, exc) logger.warning('Error while getting cover image for archive %s, %s', self.archive, exc)
Expand Down
Loading

1 comment on commit 37f4cd5

@charrea6
Copy link

Choose a reason for hiding this comment

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

Looking good, only some comments on the use of the new dialogs.
Thanks for fixing the message dialog, but the status dialog should be reverted please.
When you want to indicate to the user that you're doing something and the user has to wait, use dialog.show_working_indicator().
When you want the user to confirm they've seen something, use dialog.show_alert()
When you just want the user to know something but not interrupt them, use dialog.show_message(). For example you may want to use this when a download has finished, as they probably don't want to interrupt what they are doing to close a box saying something has finished downloading...

Please sign in to comment.