Beispiel #1
0
    def new(self):
        self._config.connect_gtk_togglebutton('maemo_enable_gestures',
                                              self.check_enable_gestures)
        self._config.connect_gtk_togglebutton('podcast_list_view_all',
                                              self.check_podcast_list_view_all)

        self.main_window.connect('destroy', lambda w: self.callback_finished())

        for item in self.audio_players:
            command, caption = item
            if util.find_command(command) is None and command != 'default':
                self.audio_players.remove(item)

        for item in self.video_players:
            command, caption = item
            if util.find_command(command) is None and command != 'default':
                self.video_players.remove(item)

        # Set up the audio player combobox
        found = False
        self.userconfigured_player = None
        for id, audio_player in enumerate(self.audio_players):
            command, caption = audio_player
            self.combo_player_model.append([caption])
            if self._config.player == command:
                self.combo_player.set_active(id)
                found = True
        if not found:
            self.combo_player_model.append(
                ['User-configured (%s)' % self._config.player])
            self.combo_player.set_active(len(self.combo_player_model) - 1)
            self.userconfigured_player = self._config.player

        # Set up the video player combobox
        found = False
        self.userconfigured_videoplayer = None
        for id, video_player in enumerate(self.video_players):
            command, caption = video_player
            self.combo_videoplayer_model.append([caption])
            if self._config.videoplayer == command:
                self.combo_videoplayer.set_active(id)
                found = True
        if not found:
            self.combo_videoplayer_model.append(
                ['User-configured (%s)' % self._config.videoplayer])
            self.combo_videoplayer.set_active(
                len(self.combo_videoplayer_model) - 1)
            self.userconfigured_videoplayer = self._config.videoplayer

        self.gPodderPreferences.show()
Beispiel #2
0
def get_track_length(filename):
    length = gstreamer.get_track_length(filename)
    if length is not None:
        return length

    if util.find_command('mplayer') is not None:
        try:
            mplayer_output = os.popen('mplayer -msglevel all=-1 -identify -vo null -ao null -frames 0 "%s" 2>/dev/null' % filename).read()
            return int(float(mplayer_output[mplayer_output.index('ID_LENGTH'):].splitlines()[0][10:])*1000)
        except:
            pass
    else:
        log('Please install MPlayer for track length detection.')

    try:
        mad_info = mad.MadFile(filename)
        return int(mad_info.total_time())
    except:
        pass
    
    try:
        eyed3_info = eyeD3.Mp3AudioFile(filename)
        return int(eyed3_info.getPlayTime()*1000)
    except:
        pass

    return int(60*60*1000*3) # Default is three hours (to be on the safe side)
    def new(self):
        self._config.connect_gtk_togglebutton('on_quit_ask', self.check_ask_on_quit)
        self._config.connect_gtk_togglebutton('maemo_enable_gestures', self.check_enable_gestures)
        self._config.connect_gtk_togglebutton('podcast_list_view_all', self.check_podcast_list_view_all)

        self.main_window.connect('destroy', lambda w: self.callback_finished())

        for item in self.audio_players:
            command, caption = item
            if util.find_command(command) is None and command != 'default':
                self.audio_players.remove(item)

        for item in self.video_players:
            command, caption = item
            if util.find_command(command) is None and command != 'default':
                self.video_players.remove(item)

        # Set up the audio player combobox
        found = False
        self.userconfigured_player = None
        for id, audio_player in enumerate(self.audio_players):
            command, caption = audio_player
            self.combo_player_model.append([caption])
            if self._config.player == command:
                self.combo_player.set_active(id)
                found = True
        if not found:
            self.combo_player_model.append(['User-configured (%s)' % self._config.player])
            self.combo_player.set_active(len(self.combo_player_model)-1)
            self.userconfigured_player = self._config.player

        # Set up the video player combobox
        found = False
        self.userconfigured_videoplayer = None
        for id, video_player in enumerate(self.video_players):
            command, caption = video_player
            self.combo_videoplayer_model.append([caption])
            if self._config.videoplayer == command:
                self.combo_videoplayer.set_active(id)
                found = True
        if not found:
            self.combo_videoplayer_model.append(['User-configured (%s)' % self._config.videoplayer])
            self.combo_videoplayer.set_active(len(self.combo_videoplayer_model)-1)
            self.userconfigured_videoplayer = self._config.videoplayer

        self.gPodderPreferences.show()
 def has_converter(self, extension):
     if util.find_command('lame') is not None:
         extension=extension.lower()
         if extension[0] == '.':
             extension=extension[1:]
         return self.has_key(extension)
     else:
         log('Please install the "lame" package to convert files.', sender=self)
         return False
Beispiel #5
0
 def add_converter(self, extension, command, arguments):
     if util.find_command(command) is not None:
         log('Found "%s", will try to convert ".%s" files.' %
             (command, extension),
             sender=self)
         self[extension.lower()] = FileConverter(command, arguments)
     else:
         log('Could not find "%s", ".%s" files cannot be converted.' %
             (command, extension),
             sender=self)
Beispiel #6
0
    def require_command(self, command):
        """Checks if the given command is installed on the system

        Returns the complete path of the command

        @param command: String with the command name
        """
        result = util.find_command(command)
        if result is None:
            msg = _('Command not found: %(command)s') % {'command': command}
            raise MissingCommand(msg, command)
        return result
Beispiel #7
0
    def require_command(self, command):
        """Checks if the given command is installed on the system

        Returns the complete path of the command

        @param command: String with the command name
        """
        result = util.find_command(command)
        if result is None:
            msg = _('Command not found: %(command)s') % {'command': command}
            raise MissingCommand(msg, command)
        return result
Beispiel #8
0
 def has_converter(self, extension):
     if util.find_command('lame') is not None:
         extension = extension.lower()
         if len(extension) == 0:
             log('Cannot find a converter without extension.', sender=self)
             return False
         if extension[0] == '.':
             extension = extension[1:]
         return self.has_key(extension)
     else:
         log('Please install the "lame" package to convert files.',
             sender=self)
         return False
Beispiel #9
0
    def tools_available(self, tools):
        """
        See modules_available.
        """
        result = {}
        all_available = True
        for tool in tools:
            if util.find_command(tool):
                result[tool] = True
            else:
                result[tool] = False
                all_available = False

        return (all_available, result)
Beispiel #10
0
def get_track_length(filename):
    if util.find_command('mplayer') is not None:
        try:
            mplayer_output = os.popen('mplayer -msglevel all=-1 -identify -vo null -ao null -frames 0 "%s" 2>/dev/null' % filename).read()
            return int(float(mplayer_output[mplayer_output.index('ID_LENGTH'):].splitlines()[0][10:])*1000)
        except:
            pass
    else:
        logger.info('Please install MPlayer for track length detection.')

    try:
        mp3file = eyed3.mp3.Mp3AudioFile(filename)
        return int(mp3file.info.time_secs * 1000)
    except Exception, e:
        logger.warn('Could not determine length: %s', filename, exc_info=True)
Beispiel #11
0
    def require_any_command(self, command_list):
        """Checks if any of the given commands is installed on the system

        Returns the complete path of first found command in the list

        @param command: List with the commands name
        """
        for command in command_list:
            result = util.find_command(command)
            if result is not None:
                return result

        msg = _('Need at least one of the following commands: %(list_of_commands)s') % \
            {'list_of_commands': ', '.join(command_list)}
        raise MissingCommand(msg, ', '.join(command_list))
Beispiel #12
0
    def require_any_command(self, command_list):
        """Checks if any of the given commands is installed on the system

        Returns the complete path of first found command in the list

        @param command: List with the commands name
        """
        for command in command_list:
            result = util.find_command(command)
            if result is not None:
                return result

        msg = _('Need at least one of the following commands: %(list_of_commands)s') % \
            {'list_of_commands': ', '.join(command_list)}
        raise MissingCommand(msg, ', '.join(command_list))
Beispiel #13
0
def get_track_length(filename):
    if util.find_command('mplayer') is not None:
        try:
            mplayer_output = os.popen('mplayer -msglevel all=-1 -identify -vo null -ao null -frames 0 "%s" 2>/dev/null' % filename).read()
            return int(float(mplayer_output[mplayer_output.index('ID_LENGTH'):].splitlines()[0][10:])*1000)
        except:
            pass
    else:
        logger.info('Please install MPlayer for track length detection.')

    try:
        mp3file = eyed3.mp3.Mp3AudioFile(filename)
        return int(mp3file.info.time_secs * 1000)
    except Exception, e:
        logger.warn('Could not determine length: %s', filename, exc_info=True)
Beispiel #14
0
def get_track_length(filename):
    if util.find_command('mplayer') is not None:
        try:
            mplayer_output = os.popen('mplayer -msglevel all=-1 -identify -vo null -ao null -frames 0 "%s" 2>/dev/null' % filename).read()
            return int(float(mplayer_output[mplayer_output.index('ID_LENGTH'):].splitlines()[0][10:])*1000)
        except:
            pass
    else:
        log('Please install MPlayer for track length detection.')

    try:
        eyed3_info = eyeD3.Mp3AudioFile(filename)
        return int(eyed3_info.getPlayTime()*1000)
    except:
        pass

    return int(60*60*1000*3) # Default is three hours (to be on the safe side)
Beispiel #15
0
    def invoke_torrent( self, url, torrent_filename, target_filename):
        self.history_mark_played( url)

        if self.config.use_gnome_bittorrent:
            if util.find_command('gnome-btdownload') is None:
                log( 'Cannot find "gnome-btdownload". Please install gnome-bittorrent.', sender=self)
                return False

            command='gnome-btdownload "%s" --saveas "%s"' % ( torrent_filename, os.path.join( self.config.bittorrent_dir, target_filename))
            log( command, sender=self)
            os.system( '%s &' % command)
            return True
        else:
            # Simply copy the .torrent with a suitable name
            try:
                target_filename=os.path.join( self.config.bittorrent_dir, os.path.splitext( target_filename)[0] + '.torrent')
                shutil.copyfile( torrent_filename, target_filename)
                return True
            except:
                log( 'Torrent copy failed: %s => %s.', torrent_filename, target_filename)

        return False
Beispiel #16
0
    def __init__(self, container):
        self.container = container

        program = shlex.split(FFMPEG_CMD)[0]
        if not util.find_command(program):
            raise ImportError("Couldn't find program '%s'" % program)
Beispiel #17
0
 def check_mediaplayer(self, cmd):
     return not (util.find_command(cmd) == None)
Beispiel #18
0
 def require_command(self, command):
     result = util.find_command(command)
     if result is None:
         msg = _('Command not found: %(command)s') % {'command': command}
         raise MissingCommand(msg, command)
     return result
 def is_installed(self):
     return util.find_command(self.command[0]) is not None
 def is_installed(self):
     if gpodder.ui.win32:
         return False
     return util.find_command(self.command[0]) is not None
 def add_converter( self, extension, command, arguments):
     if util.find_command(command) is not None:
         log( 'Found "%s", will try to convert ".%s" files.' % ( command, extension ), sender = self)
         self[extension.lower()] = FileConverter( command, arguments)
     else:
         log( 'Could not find "%s", ".%s" files cannot be converted.' % ( command, extension ), sender = self)
 def __init__(self, container):
     self.container = container
     self.gpodder = None
     self.have_ffmpeg = (util.find_command('ffmpeg') is not None)
Beispiel #23
0
    def new(self):
        # Store the current configuration options in case we cancel later
        self._config_backup = self._config.get_backup()
        self._do_restore_config = True
        self.main_window.connect('destroy', self.on_destroy)

        self.save_button = self.main_window.add_button(gtk.STOCK_SAVE, 1)
        self.save_button.connect('clicked', self.on_save_button_clicked)

        self.touch_selector_orientation = hildon.TouchSelector(text=True)
        for caption in FremantleRotation.MODE_CAPTIONS:
            self.touch_selector_orientation.append_text(caption)
        self.touch_selector_orientation.set_active(0,
                                                   self._config.rotation_mode)
        self.picker_orientation.set_selector(self.touch_selector_orientation)

        if not self._config.auto_update_feeds:
            self._config.auto_update_frequency = 0

        # Create a mapping from minute values to touch selector indices
        minute_index_mapping = dict(
            (b, a) for a, b in enumerate(x[0] for x in self.UPDATE_INTERVALS))

        self.touch_selector_interval = hildon.TouchSelector(text=True)
        for value, caption in self.UPDATE_INTERVALS:
            self.touch_selector_interval.append_text(caption)
        interval = self._config.auto_update_frequency
        if interval in minute_index_mapping:
            self._custom_interval = 0
            self.touch_selector_interval.set_active(
                0, minute_index_mapping[interval])
        else:
            self._custom_interval = self._config.auto_update_frequency
            self.touch_selector_interval.append_text(
                N_('Every %(count)d minute', 'Every %(count)d minutes',
                   interval) % {'count': interval})
            self.touch_selector_interval.set_active(0,
                                                    len(self.UPDATE_INTERVALS))
        self.picker_interval.set_selector(self.touch_selector_interval)

        # Create a mapping from download methods to touch selector indices
        download_method_mapping = dict(
            (b, a) for a, b in enumerate(x[0] for x in self.DOWNLOAD_METHODS))

        self.touch_selector_download = hildon.TouchSelector(text=True)
        for value, caption in self.DOWNLOAD_METHODS:
            self.touch_selector_download.append_text(caption)

        if self._config.auto_download not in (x[0]
                                              for x in self.DOWNLOAD_METHODS):
            self._config.auto_download = self.DOWNLOAD_METHODS[0][0]

        self.touch_selector_download.set_active(
            0, download_method_mapping[self._config.auto_download])
        self.picker_download.set_selector(self.touch_selector_download)

        # Determine possible audio and video players (only installed ones)
        self.audio_players = [(c, l) for c, l in self.AUDIO_PLAYERS
                              if c == 'default' or util.find_command(c)]
        self.video_players = [(c, l) for c, l in self.VIDEO_PLAYERS
                              if c == 'default' or util.find_command(c)]

        # Create a mapping from audio players to touch selector indices
        audio_player_mapping = dict(
            (b, a) for a, b in enumerate(x[0] for x in self.audio_players))

        self.touch_selector_audio_player = hildon.TouchSelector(text=True)
        for value, caption in self.audio_players:
            self.touch_selector_audio_player.append_text(caption)

        if self._config.player not in (x[0] for x in self.audio_players):
            self._config.player = self.audio_players[0][0]

        self.touch_selector_audio_player.set_active(
            0, audio_player_mapping[self._config.player])
        self.picker_audio_player.set_selector(self.touch_selector_audio_player)

        # Create a mapping from video players to touch selector indices
        video_player_mapping = dict(
            (b, a) for a, b in enumerate(x[0] for x in self.video_players))

        self.touch_selector_video_player = hildon.TouchSelector(text=True)
        for value, caption in self.video_players:
            self.touch_selector_video_player.append_text(caption)

        if self._config.videoplayer not in (x[0] for x in self.video_players):
            self._config.videoplayer = self.video_players[0][0]

        self.touch_selector_video_player.set_active(
            0, video_player_mapping[self._config.videoplayer])
        self.picker_video_player.set_selector(self.touch_selector_video_player)

        # Fix the styling and layout of the picker buttons
        for button in (self.picker_orientation, \
                       self.picker_interval, \
                       self.picker_download, \
                       self.picker_audio_player, \
                       self.picker_video_player):
            # Work around Maemo bug #4718
            button.set_name('HildonButton-finger')
            # Fix alignment problems (Maemo bug #6205)
            button.set_alignment(.0, .5, 1., 0.)
            child = button.get_child()
            child.set_padding(0, 0, 12, 0)

        self.button_enable_mygpo.set_name('HildonCheckButton-finger')

        self.check_view_all_episodes = hildon.CheckButton(
            gtk.HILDON_SIZE_FINGER_HEIGHT)
        self.check_view_all_episodes.set_label(_('Show "All episodes" view'))
        self.check_view_all_episodes.set_active(
            self._config.podcast_list_view_all)
        self.pannable_vbox.add(self.check_view_all_episodes)
        self.pannable_vbox.reorder_child(self.check_view_all_episodes, 2)

        # Disable capitalization word completion
        self.entry_mygpo_username.set_property('hildon-input-mode', \
                gtk.HILDON_GTK_INPUT_MODE_FULL)
        self.entry_mygpo_password.set_property('hildon-input-mode', \
                gtk.HILDON_GTK_INPUT_MODE_FULL)

        self.entry_mygpo_password.set_visibility(False)

        self.button_enable_mygpo.set_active(self._config.mygpo_enabled)
        self.entry_mygpo_username.set_text(self._config.mygpo_username)
        self.entry_mygpo_password.set_text(self._config.mygpo_password)
        self.entry_mygpo_device.set_text(self._config.mygpo_device_caption)

        if self._config.auto_remove_played_episodes:
            adjustment_expiration = self.hscale_expiration.get_adjustment()
            if self._config.episode_old_age > adjustment_expiration.upper:
                # Patch the adjustment to include the higher current value
                adjustment_expiration.upper = self._config.episode_old_age

            self.hscale_expiration.set_value(self._config.episode_old_age)
        else:
            self.hscale_expiration.set_value(0)

        self.gPodderPreferences.show_all()
Beispiel #24
0
pymtp_available = False
gpod_available = True
try:
    import gpod
except:
    gpod_available = False

# pymtp_available = True
# try:
#     import gpodder.gpopymtp as pymtp
# except:
#     pymtp_available = False
#     logger.warning('Could not load gpopymtp (libmtp not installed?).')

mplayer_available = True if util.find_command('mplayer') is not None else False

eyed3mp3_available = True
try:
    import eyed3.mp3
except:
    eyed3mp3_available = False

if pymtp_available:

    class MTP(pymtp.MTP):
        sep = os.path.sep

        def __init__(self):
            pymtp.MTP.__init__(self)
            self.folders = {}
Beispiel #25
0
 def is_installed(self):
     return util.find_command(self.command[0]) is not None
 def __init__(self, container):
     self.container = container
     self.gpodder = None
     self.have_ffmpeg = (util.find_command('ffmpeg') is not None)
 def check_mediaplayer(self, cmd):
     return not (util.find_command(cmd) == None)
 def is_installed(self):
     if gpodder.ui.win32:
         return False
     return util.find_command(self.command[0]) is not None
    def new(self):
        # Store the current configuration options in case we cancel later
        self._config_backup = self._config.get_backup()
        self._do_restore_config = True
        self.main_window.connect('destroy', self.on_destroy)

        self.save_button = self.main_window.add_button(gtk.STOCK_SAVE, 1)
        self.save_button.connect('clicked', self.on_save_button_clicked)

        self.touch_selector_orientation = hildon.TouchSelector(text=True)
        for caption in FremantleRotation.MODE_CAPTIONS:
            self.touch_selector_orientation.append_text(caption)
        self.touch_selector_orientation.set_active(0, self._config.rotation_mode)
        self.picker_orientation.set_selector(self.touch_selector_orientation)

        if not self._config.auto_update_feeds:
            self._config.auto_update_frequency = 0

        # Create a mapping from minute values to touch selector indices
        minute_index_mapping = dict((b, a) for a, b in enumerate(x[0] for x in self.UPDATE_INTERVALS))

        self.touch_selector_interval = hildon.TouchSelector(text=True)
        for value, caption in self.UPDATE_INTERVALS:
            self.touch_selector_interval.append_text(caption)
        interval = self._config.auto_update_frequency
        if interval in minute_index_mapping:
            self._custom_interval = 0
            self.touch_selector_interval.set_active(0, minute_index_mapping[interval])
        else:
            self._custom_interval = self._config.auto_update_frequency
            self.touch_selector_interval.append_text(N_('Every %(count)d minute', 'Every %(count)d minutes', interval) % {'count':interval})
            self.touch_selector_interval.set_active(0, len(self.UPDATE_INTERVALS))
        self.picker_interval.set_selector(self.touch_selector_interval)

        # Create a mapping from download methods to touch selector indices
        download_method_mapping = dict((b, a) for a, b in enumerate(x[0] for x in self.DOWNLOAD_METHODS))

        self.touch_selector_download = hildon.TouchSelector(text=True)
        for value, caption in self.DOWNLOAD_METHODS:
            self.touch_selector_download.append_text(caption)

        if self._config.auto_download not in (x[0] for x in self.DOWNLOAD_METHODS):
            self._config.auto_download = self.DOWNLOAD_METHODS[0][0]

        self.touch_selector_download.set_active(0, download_method_mapping[self._config.auto_download])
        self.picker_download.set_selector(self.touch_selector_download)

        # Determine possible audio and video players (only installed ones)
        self.audio_players = [(c, l) for c, l in self.AUDIO_PLAYERS if c == 'default' or util.find_command(c)]
        self.video_players = [(c, l) for c, l in self.VIDEO_PLAYERS if c == 'default' or util.find_command(c)]

        # Create a mapping from audio players to touch selector indices
        audio_player_mapping = dict((b, a) for a, b in enumerate(x[0] for x in self.audio_players))

        self.touch_selector_audio_player = hildon.TouchSelector(text=True)
        for value, caption in self.audio_players:
            self.touch_selector_audio_player.append_text(caption)

        if self._config.player not in (x[0] for x in self.audio_players):
            self._config.player = self.audio_players[0][0]

        self.touch_selector_audio_player.set_active(0, audio_player_mapping[self._config.player])
        self.picker_audio_player.set_selector(self.touch_selector_audio_player)

        # Create a mapping from video players to touch selector indices
        video_player_mapping = dict((b, a) for a, b in enumerate(x[0] for x in self.video_players))

        self.touch_selector_video_player = hildon.TouchSelector(text=True)
        for value, caption in self.video_players:
            self.touch_selector_video_player.append_text(caption)

        if self._config.videoplayer not in (x[0] for x in self.video_players):
            self._config.videoplayer = self.video_players[0][0]

        self.touch_selector_video_player.set_active(0, video_player_mapping[self._config.videoplayer])
        self.picker_video_player.set_selector(self.touch_selector_video_player)

        # Fix the styling and layout of the picker buttons
        for button in (self.picker_orientation, \
                       self.picker_interval, \
                       self.picker_download, \
                       self.picker_audio_player, \
                       self.picker_video_player):
            # Work around Maemo bug #4718
            button.set_name('HildonButton-finger')
            # Fix alignment problems (Maemo bug #6205)
            button.set_alignment(.0, .5, 1., 0.)
            child = button.get_child()
            child.set_padding(0, 0, 12, 0)

        self.button_enable_mygpo.set_name('HildonCheckButton-finger')

        self.check_view_all_episodes = hildon.CheckButton(gtk.HILDON_SIZE_FINGER_HEIGHT)
        self.check_view_all_episodes.set_label(_('Show "All episodes" view'))
        self.check_view_all_episodes.set_active(self._config.podcast_list_view_all)
        self.pannable_vbox.add(self.check_view_all_episodes)
        self.pannable_vbox.reorder_child(self.check_view_all_episodes, 2)

        # Disable capitalization word completion
        self.entry_mygpo_username.set_property('hildon-input-mode', \
                gtk.HILDON_GTK_INPUT_MODE_FULL)
        self.entry_mygpo_password.set_property('hildon-input-mode', \
                gtk.HILDON_GTK_INPUT_MODE_FULL)

        self.entry_mygpo_password.set_visibility(False)

        self.button_enable_mygpo.set_active(self._config.mygpo_enabled)
        self.entry_mygpo_username.set_text(self._config.mygpo_username)
        self.entry_mygpo_password.set_text(self._config.mygpo_password)
        self.entry_mygpo_device.set_text(self._config.mygpo_device_caption)

        if self._config.auto_remove_played_episodes:
            adjustment_expiration = self.hscale_expiration.get_adjustment()
            if self._config.episode_old_age > adjustment_expiration.upper:
                # Patch the adjustment to include the higher current value
                adjustment_expiration.upper = self._config.episode_old_age

            self.hscale_expiration.set_value(self._config.episode_old_age)
        else:
            self.hscale_expiration.set_value(0)

        self.gPodderPreferences.show_all()
Beispiel #30
0
    def __init__(self, container):
        self.container = container

        program = shlex.split(FFMPEG_CMD)[0]
        if not util.find_command(program):
            raise ImportError("Couldn't find program '%s'" % program)