Пример #1
0
class GriffithExtension(Base):
    name = 'Player'
    description = _('Plays movie trailer')
    author = 'Piotr Ożarowski'
    email = '*****@*****.**'
    version = 1
    api = 1
    enabled = False  # disabled by default

    preferences = {
        'command': {
            'name': _('Command'),
            'hint': _('{1} (if given) will be replaced with file path'),
            'default': 'mplayer {1}',
            'type': unicode
        }
    }
    if is_windows_system():
        preferences['command']['default'] = ''

    toolbar_icon = 'ge_player.png'

    def toolbar_icon_clicked(self, widget, movie):
        if not movie or not movie.trailer:
            return False

        use_shell = True
        command = self.get_config_value('command',
                                        self.preferences['command']['default'])
        if is_windows_system():
            use_shell = False  # Popen with shell=True doesn't work under windows with spaces in filenames
            if not command:
                import win32api
                log.debug('try ShellExecute with trailer %s' % movie.trailer)
                win32api.ShellExecute(0, None, movie.trailer, None, None, 0)
                return

        if '{1}' in command:
            command = command.replace('{1}', movie.trailer)
        else:
            # make a sequence results in Popen calls list2cmdline
            command = [command, movie.trailer]

        log.debug(command)
        Popen(command, shell=use_shell)

    def maintree_clicked(self, selection, movie):
        if movie and movie.trailer:
            self.toolbar_icon_widget.set_sensitive(True)
        else:
            self.toolbar_icon_widget.set_sensitive(False)
Пример #2
0
	def check_for_window(self):
		# on windows systems all output to stdout goes to a black hole
		# if py2exe is used.
		# so we use a normal window and redirect output from sys.stderr
		# and sys.stdout. it is easier to use for windows users.
		try:
			if self.debug_mode and self.debugWindow is None:
				import gutils, sys
				if gutils.is_windows_system():
					self.debugWindow = DebugWindow(None)
					sys.stderr = sys.stdout = DebugWindowRedirector(self.debugWindow)
				else:
					self.debugWindow = False
		except:
			pass
Пример #3
0
    def toolbar_icon_clicked(self, widget, movie):
        if not movie or not movie.trailer:
            return False

        use_shell = True
        command = self.get_config_value('command', self.preferences['command']['default'])
        if is_windows_system():
            use_shell = False # Popen with shell=True doesn't work under windows with spaces in filenames
            if not command:
                import win32api
                log.debug('try ShellExecute with trailer %s' % movie.trailer)
                win32api.ShellExecute(0, None, movie.trailer, None, None, 0)
                return

        if '{1}' in command:
            command = command.replace('{1}', movie.trailer)
        else:
            # make a sequence results in Popen calls list2cmdline
            command = [command, movie.trailer]

        log.debug(command)
        Popen(command, shell=use_shell)
Пример #4
0
    def toolbar_icon_clicked(self, widget, movie):
        if not movie or not movie.trailer:
            return False

        use_shell = True
        command = self.get_config_value('command',
                                        self.preferences['command']['default'])
        if is_windows_system():
            use_shell = False  # Popen with shell=True doesn't work under windows with spaces in filenames
            if not command:
                import win32api
                log.debug('try ShellExecute with trailer %s' % movie.trailer)
                win32api.ShellExecute(0, None, movie.trailer, None, None, 0)
                return

        if '{1}' in command:
            command = command.replace('{1}', movie.trailer)
        else:
            # make a sequence results in Popen calls list2cmdline
            command = [command, movie.trailer]

        log.debug(command)
        Popen(command, shell=use_shell)
 def process_movie_value(self, document, dvdelement, key, value):
     if key == 'movies_number':
         dvdelement.setAttribute('id', value)
     elif key == 'movies_loaned':
         pass
     elif key == 'movies_seen':
         dvdelement.setAttribute('seen', value)
     elif key == 'movies_rating':
         dvdelement.setAttribute('rating', value)
     elif key == 'movies_color':             # SmallInteger
         pass
     elif key == 'movies_cond':              # SmallInteger
         pass
     elif key == 'movies_layers':            # SmallInteger
         pass
     elif key == 'movies_media_num':         # SmallInteger
         dvdelement.setAttribute('number', value)
     elif key == 'movies_runtime':           # Integer
         dvdelement.setAttribute('time', value)
     elif key == 'movies_year':              # year
         dvdelement.setAttribute('date', value)
     elif key == 'movies_o_title':           # VARCHAR
         dvdelement.setAttribute('original', value)
     elif key == 'movies_title':             # VARCHAR
         dvdelement.setAttribute('title', value)
     elif key == 'movies_director':          # VARCHAR
         dvdelement.setAttribute('director', value)
     elif key == 'movies_o_site':            # VARCHAR
         pass
     elif key == 'movies_site':              # VARCHAR
         dvdelement.setAttribute('webPage', value)
     elif key == 'movies_trailer':           # VARCHAR
         if len(value.strip()) > 0:
             trailersplit = value.split('file://')
             if len(trailersplit) > 1:
                 if gutils.is_windows_system():
                     dvdelement.setAttribute('trailer', trailersplit[1].lstrip('/'))
                 else:
                     dvdelement.setAttribute('trailer', trailersplit[1])
             else:
                 dvdelement.setAttribute('trailer', trailersplit[0])
     elif key == 'movies_country':           # VARCHAR
         dvdelement.setAttribute('country', value)
     elif key == 'movies_genre':             # VARCHAR
         dvdelement.setAttribute('genre', value.replace('\n', ''))
     elif key == 'movies_region':            # SmallInteger
         pass
     elif key == 'movies_studio':            # VARCHAR
         pass
     elif key == 'movies_classification':    # VARCHAR
         dvdelement.setAttribute('age', str(gutils.digits_only(value)))
     elif key == 'movies_cast':              # VARCHAR
         if len(value.strip()) > 0:
             actors = value.split('\n')
             actorsstring = ''
             delim = ''
             for actor in actors:
                 actorsplit = actor.split(_(' as '))
                 actornames = actorsplit[0]
                 role = ''
                 if len(actorsplit) > 1:
                     role = actorsplit[1]
                 actorsstring += delim + actornames.strip() + ' (' + role.strip() + ')'
                 delim = ', '
             dvdelement.setAttribute('actors', actorsstring)
     elif key == 'movies_plot':              # VARCHAR
         elem = document.createElement('synopsis')
         dvdelement.appendChild(elem)
         t = document.createTextNode(value)
         elem.appendChild(t)
     elif key == 'movies_notes':             # VARCHAR
         elem = document.createElement('comment')
         dvdelement.appendChild(elem)
         t = document.createTextNode(value)
         elem.appendChild(t)
     elif key == 'volumes_name':             # VARCHAR
         dvdelement.setAttribute('place', value)
     elif key == 'collections_name':         # VARCHAR
         dvdelement.setAttribute('serie', value)
     elif key == 'vcodecs_name':             # VARCHAR
         dvdelement.setAttribute('video', value)
     elif key == 'media_name':               # VARCHAR
         dvdelement.setAttribute('format', value)
Пример #6
0
 def process_movie_value(self, document, dvdelement, key, value):
     if key == 'movies_number':
         dvdelement.setAttribute('id', value)
     elif key == 'movies_loaned':
         pass
     elif key == 'movies_seen':
         dvdelement.setAttribute('seen', value)
     elif key == 'movies_rating':
         dvdelement.setAttribute('rating', value)
     elif key == 'movies_color':  # SmallInteger
         pass
     elif key == 'movies_cond':  # SmallInteger
         pass
     elif key == 'movies_layers':  # SmallInteger
         pass
     elif key == 'movies_media_num':  # SmallInteger
         dvdelement.setAttribute('number', value)
     elif key == 'movies_runtime':  # Integer
         dvdelement.setAttribute('time', value)
     elif key == 'movies_year':  # year
         dvdelement.setAttribute('date', value)
     elif key == 'movies_o_title':  # VARCHAR
         dvdelement.setAttribute('original', value)
     elif key == 'movies_title':  # VARCHAR
         dvdelement.setAttribute('title', value)
     elif key == 'movies_director':  # VARCHAR
         dvdelement.setAttribute('director', value)
     elif key == 'movies_o_site':  # VARCHAR
         pass
     elif key == 'movies_site':  # VARCHAR
         dvdelement.setAttribute('webPage', value)
     elif key == 'movies_trailer':  # VARCHAR
         if len(value.strip()) > 0:
             trailersplit = value.split('file://')
             if len(trailersplit) > 1:
                 if gutils.is_windows_system():
                     dvdelement.setAttribute('trailer',
                                             trailersplit[1].lstrip('/'))
                 else:
                     dvdelement.setAttribute('trailer', trailersplit[1])
             else:
                 dvdelement.setAttribute('trailer', trailersplit[0])
     elif key == 'movies_country':  # VARCHAR
         dvdelement.setAttribute('country', value)
     elif key == 'movies_genre':  # VARCHAR
         dvdelement.setAttribute('genre', value.replace('\n', ''))
     elif key == 'movies_region':  # SmallInteger
         pass
     elif key == 'movies_studio':  # VARCHAR
         pass
     elif key == 'movies_classification':  # VARCHAR
         dvdelement.setAttribute('age', str(gutils.digits_only(value)))
     elif key == 'movies_cast':  # VARCHAR
         if len(value.strip()) > 0:
             actors = value.split('\n')
             actorsstring = ''
             delim = ''
             for actor in actors:
                 actorsplit = actor.split(_(' as '))
                 actornames = actorsplit[0]
                 role = ''
                 if len(actorsplit) > 1:
                     role = actorsplit[1]
                 actorsstring += delim + actornames.strip(
                 ) + ' (' + role.strip() + ')'
                 delim = ', '
             dvdelement.setAttribute('actors', actorsstring)
     elif key == 'movies_plot':  # VARCHAR
         elem = document.createElement('synopsis')
         dvdelement.appendChild(elem)
         t = document.createTextNode(value)
         elem.appendChild(t)
     elif key == 'movies_notes':  # VARCHAR
         elem = document.createElement('comment')
         dvdelement.appendChild(elem)
         t = document.createTextNode(value)
         elem.appendChild(t)
     elif key == 'volumes_name':  # VARCHAR
         dvdelement.setAttribute('place', value)
     elif key == 'collections_name':  # VARCHAR
         dvdelement.setAttribute('serie', value)
     elif key == 'vcodecs_name':  # VARCHAR
         dvdelement.setAttribute('video', value)
     elif key == 'media_name':  # VARCHAR
         dvdelement.setAttribute('format', value)