Hi!
Using Rhythmbox 3.4.2 and python3.6.

My goal is to force Rhythmbox to accept file formats normally not
supported (.vgm) through a Python plugin.

I failed and I am too naive to understand what is going on in the C code.

I see running rhythmbox -d that on importing there are some messages
informing about querying for metadata, and it seems the decision on
whether to let the entry importable in the source is based on such metadata.

Also (rhythmdb.c, line 2481) the body of function
```C
static gboolean
rhythmdb_process_metadata_load (RhythmDB *db, RhythmDBEvent *event)
```
convinced me that there is no way to let in whatever file I would wish
in without digging deeper in the internal workings (by e.g. creating and
injecting bogus events or metadata).

1. Is my goal a use case for a plugin?
2. If so: any comments or suggestions?

I attach some code I wrote. The idea is to register a type in the Music
source, and then see if some of the 'MyEntryType.do_*' methods magically
trigger. (They don't.)

Thanks in advance for your time and attention.
-- 
-gapag
#!/usr/bin/python3.6
from gi.repository import GObject, RB, Peas


class Vgm(GObject.Object, Peas.Activatable):
    object = GObject.property(type=GObject.Object)

    def __init__(self):
        super(Vgm, self).__init__()

    def do_activate(self):
        print("Plugin activated")
        self.vgm_dir = ""
        shell = self.object
        db = shell.props.db
        entry_type = MyEntryType()
        db.register_entry_type(entry_type)

        # since I did not know how to get a reference to 
        # the Music source, I use this periphrasis.
        # I do actually get the right reference.

        music = shell.guess_source_for_uri("file:///1234.mp3")
        shell.register_entry_type_for_source(music, entry_type)

    def do_deactivate(self):
        del self.vgm_dir


class MyEntryType(RB.RhythmDBEntryType):

    #   And here I was hoping that because of the line
    #       shell.register_entry_type_for_source(music, entry_type)
    #   in Vgm.do_activate 
    #   at least one of the below methods would trigger when scanning a  
    #   directory

    def __init__(self):
        RB.RhythmDBEntryType.__init__(self, name='my-entry-type')

    def do_get_playback_uri(self, entry):
        print("*" * 800)
        return super(MyEntryType, self).do_get_playback_uri(entry)

    def do_entry_created(self, entry):
        print("@" * 800)
        return super(MyEntryType, self).do_entry_created(entry)

    def do_cache_key_to_uri(self, entry):
        print("A" * 800)
        return None

    def do_can_sync_metadata(self, entry):
        print("B" * 800)
        return None

    def do_destroy_entry(self, entry):
        print("C" * 800)
        return None

    def do_update_availability(self, entry):
        print("D" * 800)
        return None

    def do_uri_to_cache_key(self, entry):
        return None

[Plugin]
Loader=python3
Module=vgm
IAge=2
Name=AAAA
Description=A python test plugin
Authors=none
Copyright=Copyright © 2007 Your name
Website=http://some.website/
_______________________________________________
rhythmbox-devel mailing list
rhythmbox-devel@gnome.org
https://mail.gnome.org/mailman/listinfo/rhythmbox-devel

Reply via email to