コード例 #1
0
ファイル: grilo.py プロジェクト: saifulbkhan/gnome-music
    def __init__(self):
        GObject.GObject.__init__(self)
        self.playlist_path = GLib.build_filenamev([GLib.get_user_data_dir(),
                                                  "gnome-music", "playlists"])
        if not (GLib.file_test(self.playlist_path, GLib.FileTest.IS_DIR)):
            GLib.mkdir_with_parents(self.playlist_path, int("0755", 8))

        Grl.init(None)
        self.options = Grl.OperationOptions()
        self.options.set_resolution_flags(Grl.ResolutionFlags.FAST_ONLY |
                                          Grl.ResolutionFlags.IDLE_RELAY)

        self.full_options = Grl.OperationOptions()
        self.full_options.set_resolution_flags(Grl.ResolutionFlags.FULL |
                                               Grl.ResolutionFlags.IDLE_RELAY)

        self.sources = {}
        self.blacklist = ['grl-filesystem', 'grl-bookmarks', 'grl-metadata-store', 'grl-podcasts']
        self.tracker = None
        self.changed_media_ids = []
        self.pending_event_id = 0
        self.changes_pending = {'Albums': False, 'Artists': False, 'Songs': False}
        self.pending_changed_medias = []

        self.registry = Grl.Registry.get_default()

        self.sparqltracker = TrackerWrapper().tracker
コード例 #2
0
ファイル: grilo.py プロジェクト: lexruee/gnome-music
    def __init__(self):
        GObject.GObject.__init__(self)
        self.playlist_path = GLib.build_filenamev(
            [GLib.get_user_data_dir(), "gnome-music", "playlists"])
        if not (GLib.file_test(self.playlist_path, GLib.FileTest.IS_DIR)):
            GLib.mkdir_with_parents(self.playlist_path, int("0755", 8))

        Grl.init(None)
        self.options = Grl.OperationOptions()
        self.options.set_resolution_flags(Grl.ResolutionFlags.FAST_ONLY
                                          | Grl.ResolutionFlags.IDLE_RELAY)

        self.full_options = Grl.OperationOptions()
        self.full_options.set_resolution_flags(
            Grl.ResolutionFlags.FULL | Grl.ResolutionFlags.IDLE_RELAY)

        self.sources = {}
        self.blacklist = [
            'grl-filesystem', 'grl-bookmarks', 'grl-metadata-store',
            'grl-podcasts'
        ]
        self.tracker = None
        self.changed_media_ids = []
        self.pending_event_id = 0
        self.changes_pending = {
            'Albums': False,
            'Artists': False,
            'Songs': False
        }
        self.pending_changed_medias = []

        self.registry = Grl.Registry.get_default()

        self.sparqltracker = TrackerWrapper().tracker
コード例 #3
0
    def __init__(self, coremodel, coreselection):
        super().__init__()

        self._coremodel = coremodel
        self._coreselection = coreselection
        self._search_wrappers = {}
        self._thumbnail_sources = []
        self._thumbnail_sources_timeout = None
        self._wrappers = {}

        self._tracker_wrapper = TrackerWrapper()
        self._tracker_wrapper.bind_property(
            "tracker-available", self, "tracker-available",
            GObject.BindingFlags.SYNC_CREATE)

        self._tracker_wrapper.connect(
            "notify::tracker-available", self._on_tracker_available_changed)

        Grl.init(None)

        self._registry = Grl.Registry.get_default()
        config = Grl.Config.new("grl-lua-factory", "grl-theaudiodb-cover")
        config.set_api_key(self._theaudiodb_api_key)
        self._registry.add_config(config)

        self._registry.connect('source-added', self._on_source_added)
        self._registry.connect('source-removed', self._on_source_removed)

        self._registry.load_all_plugins(True)
コード例 #4
0
ファイル: test_plugin.py プロジェクト: adderly/grilo
 def __init__(self, method_name):
     super(TestMediaPlugin, self).__init__(method_name)
     Grl.init([])
     self.registry = Grl.Registry.get_default()
     self.registry.load_all()
     sources = self.registry.get_sources(False)
     if sources:
         self.plugin = sources[0]
コード例 #5
0
 def __init__(self, method_name):
     super(TestMediaPlugin, self).__init__(method_name)
     Grl.init([])
     self.registry = Grl.Registry.get_default()
     self.registry.load_all()
     sources = self.registry.get_sources(False)
     if sources:
         self.plugin = sources[0]
コード例 #6
0
def _init():
    Grl.init([])
    registry = Grl.Registry.get_default()

    fs_config = Grl.Config.new("grl-filesystem", None)
    fs_config.set_string("base-path", _tempdir)
    registry.add_config(fs_config)

    registry.load_by_id("grl-filesystem")
コード例 #7
0
 def __init__(self, method_name):
     super(TestMetadataSource, self).__init__(method_name)
     Grl.init([])
     self.registry = Grl.Registry.get_default()
     self.registry.load_all()
     ops = Grl.SupportedOps(Grl.SupportedOps.RESOLVE
                            | Grl.SupportedOps.SET_METADATA)
     sources = self.registry.get_sources_by_operations(ops, False)
     if sources:
         self.metadata_source = sources[0]
コード例 #8
0
ファイル: test_metadata_source.py プロジェクト: adderly/grilo
 def __init__(self, method_name):
     super(TestMetadataSource, self).__init__(method_name)
     Grl.init([])
     self.registry = Grl.Registry.get_default()
     self.registry.load_all()
     ops = Grl.SupportedOps(Grl.SupportedOps.RESOLVE |
                            Grl.SupportedOps.SET_METADATA)
     sources = self.registry.get_sources_by_operations(ops, False)
     if sources:
         self.metadata_source = sources[0]
コード例 #9
0
    def __init__(self, application):
        """Initiate the CoreGrilo object

        :param Application application: The Application instance to use
        """
        super().__init__()

        self._application = application
        self._coremodel = self._application.props.coremodel
        self._coreselection = application.props.coreselection
        self._log = application.props.log
        self._search_wrappers = {}
        self._thumbnail_sources = []
        self._thumbnail_sources_timeout = None
        self._wrappers = {}

        self._tracker_wrapper = TrackerWrapper(application)
        self._tracker_wrapper.bind_property("tracker-available", self,
                                            "tracker-available",
                                            GObject.BindingFlags.SYNC_CREATE)

        GLib.setenv("GRL_PLUGIN_RANKS", self._grl_plugin_ranks, True)

        Grl.init(None)

        self._registry = Grl.Registry.get_default()
        config = Grl.Config.new("grl-lua-factory", "grl-theaudiodb-cover")
        config.set_api_key(self._theaudiodb_api_key)
        self._registry.add_config(config)

        self._registry.connect('source-added', self._on_source_added)
        self._registry.connect('source-removed', self._on_source_removed)

        self._registry.load_all_plugins(False)

        tracker_available_state = self._tracker_wrapper.props.tracker_available
        if tracker_available_state != TrackerState.AVAILABLE:
            self._tracker_wrapper.connect("notify::tracker-available",
                                          self._on_tracker_available_changed)
        else:
            self._on_tracker_available_changed(None, None)

        for plugin in self._registry.get_plugins(False):
            plugin_id = plugin.get_id()
            # Activate the Tracker plugin only when TrackerWrapper
            # is available by listening to the tracker-available
            # property, so skip it here.
            if plugin_id != "grl-tracker3":
                try:
                    self._registry.activate_plugin_by_id(plugin_id)
                except GLib.GError:
                    self._log.debug(
                        "Failed to activate {} plugin.".format(plugin_id))

        weakref.finalize(self, Grl.deinit)
コード例 #10
0
 def __init__(self, method_name):
     super(TestRegistry, self).__init__(method_name)
     Grl.init([])
     self.registry = Grl.Registry.get_default()
     plugin_paths = util.GRL_PLUGIN_PATH.split(':')
     for path in plugin_paths:
         if path:
             entries = os.listdir(path)
             self.EXISTING_LIBRARY_PATH = os.path.join(path, entries[0])
             break
     print self.EXISTING_LIBRARY_PATH
コード例 #11
0
ファイル: test_registry.py プロジェクト: GNOME/grilo
 def __init__(self, method_name):
     super(TestRegistry, self).__init__(method_name)
     Grl.init([])
     self.registry = Grl.Registry.get_default()
     plugin_paths = util.GRL_PLUGIN_PATH.split(':')
     for path in plugin_paths:
         if path:
             entries = os.listdir(path)
             self.EXISTING_LIBRARY_PATH = os.path.join(path,
                                                       entries[0])
             break
     print self.EXISTING_LIBRARY_PATH
コード例 #12
0
def _init():
    Grl.init([])
    registry = Grl.Registry.get_default()

    fs_config = Grl.Config.new("grl-filesystem", None)
    fs_config.set_string("base-path", _tempdir)
    registry.add_config(fs_config)

    try:
        registry.load_plugin_by_id("grl-filesystem")
    except GLib.Error:
        pass
コード例 #13
0
ファイル: test_fs.py プロジェクト: GNOME/grilo
def _init():
    Grl.init([])
    registry = Grl.Registry.get_default()

    fs_config = Grl.Config.new("grl-filesystem", None)
    fs_config.set_string("base-path", _tempdir)
    registry.add_config(fs_config)

    try:
        registry.load_plugin_by_id("grl-filesystem")
    except GLib.Error:
        pass
コード例 #14
0
ファイル: grilo-test-ui.py プロジェクト: jors/naufrago
    def __init__(self):
        super(MainWindow, self).__init__(type=Gtk.WindowType.TOPLEVEL)
        self.connect('destroy', self._quit)
        self.set_title('Grilo Test UI using introspection')

        Grl.init([])

        self._ui_state = UIState()
        self.BROWSE_KEYS = self._lookup_browse_keys()
        self.METADATA_KEYS = self._lookup_metadata_keys()
        self._launchers = UriLaunchers()

        self._setup_ui()
        self._load_plugins()

        self.show_all()
コード例 #15
0
    def __init__(self):
        super(MainWindow, self).__init__(type=Gtk.WindowType.TOPLEVEL)
        self.connect('destroy', self._quit)
        self.set_title('Grilo Test UI using introspection')

        Grl.init([])

        self._ui_state = UIState()
        self.BROWSE_KEYS = self._lookup_browse_keys()
        self.METADATA_KEYS = self._lookup_metadata_keys()
        self._launchers = UriLaunchers()

        self._setup_ui()
        self._load_plugins()

        self.show_all()
コード例 #16
0
ファイル: grilo.py プロジェクト: rz6iox/gnome-music
    def __init__(self):
        super().__init__()

        self.playlist_path = GLib.build_filenamev(
            [GLib.get_user_data_dir(), "gnome-music", "playlists"])
        if not (GLib.file_test(self.playlist_path, GLib.FileTest.IS_DIR)):
            GLib.mkdir_with_parents(self.playlist_path, int("0755", 8))

        Grl.init(None)
        self.options = Grl.OperationOptions()
        self.options.set_resolution_flags(Grl.ResolutionFlags.FAST_ONLY
                                          | Grl.ResolutionFlags.IDLE_RELAY)

        self.full_options = Grl.OperationOptions()
        self.full_options.set_resolution_flags(
            Grl.ResolutionFlags.FULL | Grl.ResolutionFlags.IDLE_RELAY)

        self.props.sources = {}

        self.blacklist = [
            'grl-filesystem', 'grl-bookmarks', 'grl-metadata-store',
            'grl-podcasts', 'grl-spotify-cover'
        ]
        self.tracker = None
        self.changed_media_ids = []
        self.pending_event_id = 0
        self.changes_pending = {
            'Albums': False,
            'Artists': False,
            'Songs': False
        }
        self.pending_changed_medias = []

        self._thumbnail_sources = []
        self._thumbnail_sources_timeout = None

        self.registry = Grl.Registry.get_default()

        self._tracker_wrapper = TrackerWrapper()
        self.tracker_sparql = self._tracker_wrapper.props.tracker
        self._tracker_wrapper.bind_property(
            "tracker-available", self, "tracker-available",
            GObject.BindingFlags.BIDIRECTIONAL
            | GObject.BindingFlags.SYNC_CREATE)

        self._find_sources()
コード例 #17
0
ファイル: grilo.py プロジェクト: GNOME/gnome-music
    def __init__(self):
        super().__init__()

        self.playlist_path = GLib.build_filenamev([GLib.get_user_data_dir(),
                                                  "gnome-music", "playlists"])
        if not (GLib.file_test(self.playlist_path, GLib.FileTest.IS_DIR)):
            GLib.mkdir_with_parents(self.playlist_path, int("0755", 8))

        Grl.init(None)
        self.options = Grl.OperationOptions()
        self.options.set_resolution_flags(Grl.ResolutionFlags.FAST_ONLY |
                                          Grl.ResolutionFlags.IDLE_RELAY)

        self.full_options = Grl.OperationOptions()
        self.full_options.set_resolution_flags(Grl.ResolutionFlags.FULL |
                                               Grl.ResolutionFlags.IDLE_RELAY)

        self.props.sources = {}

        self.blacklist = [
            'grl-filesystem',
            'grl-bookmarks',
            'grl-metadata-store',
            'grl-podcasts',
            'grl-spotify-cover'
        ]
        self.tracker = None
        self.changed_media_ids = []
        self.pending_event_id = 0
        self.changes_pending = {'Albums': False, 'Artists': False, 'Songs': False}
        self.pending_changed_medias = []

        self._thumbnail_sources = []
        self._thumbnail_sources_timeout = None

        self.registry = Grl.Registry.get_default()

        self._tracker_wrapper = TrackerWrapper()
        self.tracker_sparql = self._tracker_wrapper.props.tracker
        self._tracker_wrapper.bind_property(
            "tracker-available", self, "tracker-available",
            GObject.BindingFlags.BIDIRECTIONAL |
            GObject.BindingFlags.SYNC_CREATE)

        self._find_sources()
コード例 #18
0
ファイル: coregrilo.py プロジェクト: AzureMentor/gnome-music
    def __init__(self, coremodel, coreselection):
        super().__init__()

        self._coremodel = coremodel
        self._coreselection = coreselection
        self._search_wrappers = {}
        self._thumbnail_sources = []
        self._thumbnail_sources_timeout = None
        self._wrappers = {}

        Grl.init(None)

        self._registry = Grl.Registry.get_default()
        config = Grl.Config.new("grl-lua-factory", "grl-theaudiodb-cover")
        config.set_api_key(self._theaudiodb_api_key)
        self._registry.add_config(config)

        self._registry.connect('source-added', self._on_source_added)
        self._registry.connect('source-removed', self._on_source_removed)

        self._registry.load_all_plugins(True)
コード例 #19
0
        self.assertEqual(d.get_minute(), 5)
        self.assertEqual(d.get_second(), 6)
        self.assertEqual(d.format("%FT%H:%M:%S%Z"),
                         date.format("%FT%H:%M:%S%Z"))

        # date only
        date_string = "2001-02-03"
        date = Grl.date_time_from_iso8601(date_string)
        media.set_publication_date(date)
        d = media.get_publication_date()
        self.assertTrue(d is not None)
        self.assertEqual(d.get_year(), 2001)
        self.assertEqual(d.get_month(), 2)
        self.assertEqual(d.get_day_of_month(), 3)
        self.assertEqual(d.get_hour(), 12)
        self.assertEqual(d.get_minute(), 0)
        self.assertEqual(d.get_second(), 0)
        self.assertEqual(d.format("%FT%H:%M:%S%Z"),
                         date.format("%FT%H:%M:%S%Z"))
        self.assertEqual(d.format("%FT%H:%M:%S%Z"),
                         date_string + "T12:00:00UTC")


# who said "this is ugly" ?
Grl.init([])
registry = Grl.Registry.get_default()
try:
    registry.load_plugin_by_id("grl-filesystem")
except GLib.Error:
    pass
コード例 #20
0
        query = None
        if isinstance(item, Grl.MediaAudio):
            query = Query.get_album_for_song_id(item_id)
        else:
            query = Query.get_album_for_album_id(item_id)

        options = self.full_options.copy()
        options.set_count(1)

        self.search_source.query(query, self.METADATA_THUMBNAIL_KEYS, options, callback, data)

    @log
    def get_playlist_with_id(self, playlist_id, callback):
        options = self.options.copy()
        query = Query.get_playlist_with_id(playlist_id)

        self.tracker.query(query, self.METADATA_KEYS, options, callback, None)

    @log
    def get_playlist_song_with_id(self, playlist_id, entry_id, callback):
        options = self.options.copy()
        query = Query.get_playlist_song_with_id(playlist_id, entry_id)

        self.tracker.query(query, self.METADATA_KEYS, options, callback, None)


Grl.init(None)

grilo = Grilo()
コード例 #21
0
ファイル: test_media.py プロジェクト: adderly/grilo
        media.set_publication_date(date)
        d = media.get_publication_date()
        self.assertTrue(d is not None)
        self.assertEqual(d.get_year(), 2001)
        self.assertEqual(d.get_month(), 2)
        self.assertEqual(d.get_day_of_month(), 3)
        self.assertEqual(d.get_hour(), 4)
        self.assertEqual(d.get_minute(), 5)
        self.assertEqual(d.get_second(), 6)
        self.assertEqual(d.format("%FT%H:%M:%S%Z"), date.format("%FT%H:%M:%S%Z"))

        # date only
        date_string = "2001-02-03"
        date = Grl.date_time_from_iso8601 (date_string)
        media.set_publication_date(date)
        d = media.get_publication_date()
        self.assertTrue(d is not None)
        self.assertEqual(d.get_year(), 2001)
        self.assertEqual(d.get_month(), 2)
        self.assertEqual(d.get_day_of_month(), 3)
        self.assertEqual(d.get_hour(), 12)
        self.assertEqual(d.get_minute(), 0)
        self.assertEqual(d.get_second(), 0)
        self.assertEqual(d.format("%FT%H:%M:%S%Z"), date.format("%FT%H:%M:%S%Z"))
        self.assertEqual(d.format("%FT%H:%M:%S%Z"), date_string + "T12:00:00UTC")

# who said "this is ugly" ?
Grl.init([])
registry = Grl.Registry.get_default()
registry.load_by_id("grl-filesystem")