Schweinepriester / beets-config

Config for https://github.com/beetbox/beets
MIT License
3 stars 4 forks source link

plugin: "beets-import-string"!? #3

Open Schweinepriester opened 9 years ago

zabelhaft commented 9 years ago

http://beets.readthedocs.org/en/v1.3.13/reference/cli.html#list damit könnte das wohl gehen? vielleicht gibt es einen "lastimport" querry? oder man killt die bib bevor man was neues importiert?

zabelhaft commented 9 years ago

http://beets.readthedocs.org/en/v1.3.13/reference/query.html#date-and-date-range-queries man könnte schonmal nach "date added" filtern

Schweinepriester commented 9 years ago

könnte vielleicht sein, aber bisher bin ich pessimistisch was die existierenden sachen angeht

aaaallerdings sollte das eigentlich ein relativ simples plugin sein:

  1. auf album_imported lauschen, siehe http://beets.readthedocs.org/en/v1.3.13/dev/plugins.html#listen-for-events
  2. für jedes album einen string ausgeben, der durch die properties des parameters album gefüllt wird, siehe:
Schweinepriester commented 9 years ago

ich denke wenn wir die initiale config haben, würde ich mich da als erstes dransetzen

sofern das nicht schon mit existierendem funktioniert

zabelhaft commented 9 years ago
beet ls -af  'Musik: $albumartist - $album ($genre - $year) @ $bitrate' 'added:2015-06-10'

sollte einen string im gewünschten format aller alben, die am 10.06.2015 importiert wurden, liefern.

zabelhaft commented 9 years ago

und den output des terminals in eine datei zu schreiben ist auch sehr simpel:

Windows: command > textfile.txt (schreibt in den aktuellen ordner)
Mac: [command] >> textfile.txt (ebenfalls aktueller ordner)

probier mal aus mit: ipconfig > output.txt

zabelhaft commented 9 years ago

wenn das so klapp -> PROFIT! für alpha 0.1 allemal gut genug ;)

Schweinepriester commented 9 years ago

joar, das dürfte definitiv klappen denke ich! und wird erstmal vermutlich auch reichen ;)

aber ich will das letztenendes ja nicht von hand machen, dafür braucht es vermutlich ein plugin, sodass man das nach erfolgreichem import direkt angezeigt kriegt.

vielleicht könnte man das so realisieren, dass nach jedem import in eine datei angehängt wird. es sei denn sie ist leer, dann legt sie den "header" (Kai, 10.06.2015 etc...) an und hängt darunter an.

in fernerer zukunft dann dass man an einer bestimmten stelle einfügt, bspw. nach dem ersten auftreten von --- ... ;)

auch gibt es nicht immer einen $albumartist, bspw. bei compilations oder soundtracks

aaaber das kann man alles natürlich immernoch entwickeln!

zabelhaft commented 9 years ago

siehe config und dann

beet ls -af  'Musik: $albumartist - $album ($genre - $year) @ $bitrate kBit/s' 'added:2015-06-10'

folgender output:

Musik: Emery - You Were Never Alone (Post-Hardcore - 2015) @ 320000.0 kBit/s
Musik: Fear, and Loathing in Las Vegas - All That We Have Now (Screamo - 2012) @ 320000.0 kBit/s
Musik: Gamma Ray - Empire of the Undead (Power Metal - 2014) @ 320000.0 kBit/s
zabelhaft commented 9 years ago

das $bitrate für alben ist in der config konstruiert

Schweinepriester commented 9 years ago

doesnt work (yet):

C:\Users\Kai>beet ls -af  'Musik: $albumartist - $album ($genre - $year) @ $bitr
ate kBit/s' 'added:2015-06-10'
Traceback (most recent call last):
  File "C:\Python27\Scripts\beet-script.py", line 9, in <module>
    load_entry_point('beets==1.3.13', 'console_scripts', 'beet')()
  File "C:\Python27\lib\site-packages\beets\ui\__init__.py", line 1104, in main
    _raw_main(args)
  File "C:\Python27\lib\site-packages\beets\ui\__init__.py", line 1094, in _raw_
main
    subcommand.func(lib, suboptions, subargs)
  File "C:\Python27\lib\site-packages\beets\ui\commands.py", line 990, in list_f
unc
    list_items(lib, decargs(args), opts.album)
  File "C:\Python27\lib\site-packages\beets\ui\commands.py", line 982, in list_i
tems
    for album in lib.albums(query):
  File "C:\Python27\lib\site-packages\beets\library.py", line 1256, in albums
    return self._fetch(Album, query, sort or self.get_default_album_sort())
  File "C:\Python27\lib\site-packages\beets\library.py", line 1226, in _fetch
    query, parsed_sort = parse_query_parts(query, model_cls)
  File "C:\Python27\lib\site-packages\beets\library.py", line 1124, in parse_que
ry_parts
    model_cls, non_path_parts, prefixes
  File "C:\Python27\lib\site-packages\beets\dbcore\queryparse.py", line 198, in
parse_sorted_query
    s = sort_from_strings(model_cls, sort_parts)
  File "C:\Python27\lib\site-packages\beets\dbcore\queryparse.py", line 163, in
sort_from_strings
    sort.add_sort(construct_sort_part(model_cls, part))
  File "C:\Python27\lib\site-packages\beets\dbcore\queryparse.py", line 136, in
construct_sort_part
    assert field, "field is missing"
AssertionError: field is missing
zabelhaft commented 9 years ago
Schweinepriester commented 9 years ago

all of the above - also, it didnt work if i excluded $bitrate

for the record, please post your output from beet config

zabelhaft commented 9 years ago

try: beet ls 'added:yyyy-mm-dd (with the correct date)

Schweinepriester commented 9 years ago

didnt work, but i partially figured it out

  1. it seems to be windows needs double quotes

    C:\Users\Hollberg>beet ls -af  "Musik: $albumartist - $album ($genre - $year) @
    $bitrate kBit/s"
    Musik: Alcest - Shelter (Shoegaze - 2014) @ 320000.0 kBit/s
  2. also works for added

    C:\Users\Hollberg>beet ls "added:2015-06-11"
    Alcest - Shelter - Wings
    Alcest - Shelter - Opale
    Alcest - Shelter - La nuit marche avec moi
    Alcest - Shelter - Voix sereines
    Alcest - Shelter - L'éveil des muses
    Alcest - Shelter - Shelter
    Alcest - Shelter - Away
    Alcest - Shelter - Délivrance
    
    C:\Users\Hollberg>beet ls 'added:2015-06-11'
    
    C:\Users\Hollberg>

but does not work combined yet

Schweinepriester commented 9 years ago

powershell to the rescue!

PS C:\Users\Hollberg> beet ls -af  'Musik: $albumartist - $album ($genre - $year) @ $bitrate kBit/s' 'added:2015-06-11'
Musik: Alcest - Shelter (Shoegaze - 2014) @ 320000.0 kBit/s

alright, lets consider this working.

i'll try to round (or similar) the bitrate, echoing e.g. @ 320 kBit/s

dont close the issue please, since it was initially intended for a automatic solution, like e.g. a plugin

Schweinepriester commented 9 years ago

works :)

PS C:\Users\Hollberg> beet ls -af  'Musik: $albumartist - $album ($genre - $year) @ $bitrate kBit/s' 'added:2015-06-11'
Musik: Alcest - Shelter (Shoegaze - 2014) @ 320 kBit/s
Schweinepriester commented 9 years ago

a little gimgick for powershell B-)

PS C:\Users\Hollberg> beet ls -af  'Musik: $albumartist - $album ($genre - $year) @ $bitrate kBit/s' 'added:$(Get-Date -
Format yyyy-MM-dd)'
Musik: Alcest - Shelter (Shoegaze - 2014) @ 320 kBit/s

sure is also possible on osx/unix-like, but i think we really should rather start a plugin, should be not too difficult

i'll try it asap :)

Schweinepriester commented 9 years ago

i just found http://beets.readthedocs.org/en/latest/reference/config.html#format-album which we could set to e.g. Musik: $albumartist - $album ($genre - $year) @ $bitrate kBit/s, which would simplify the manual call to beet ls -a 'added:2015-06-11'

untested yet, though

Schweinepriester commented 9 years ago

for the future: implement VBR if album is VBR

zabelhaft commented 9 years ago

is it useful to implement some code that defines 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256 and 320 as CBR and defines everything else als VBR?

str(bitrate)[:3]
int(bitrate)
if bitrate = {32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320}:
    return str(bitrate)
else:
    return str(bitrate) VBR

although not strictly correct, this may be a simple solution. our approach in gerneral does not work for bitrates below 100 kBit/s. it would output 990 kBit/s for an album with 99 kBit/s. Since I do not believe we would accept that bitrate in our collection, I assume it's fine.

Schweinepriester commented 9 years ago

sounds like a good first start

although we had cases in the past where the bit rate was e.g. 192 VBR, 256 VBR even 320 VBR, which would not be accurate by this check. but its a good start for most cases and those i named will be probably only detectable through file properties

oooor, just thought of it, add a check to the inital calculation for the bitrate

probalby not working code

album_fields:
    bitrate: |
        total = 0
        temp = items
        firstBitrate = next(temp).bitrate
        vbr = 0
        for item in items:
            total += item.bitrate
            if item.bitrate != firstBitrate 
                vbr = 1
        bitrate = total / len(items)
        bitratestring = str(bitrate)[:3]
        if vbr
            bitratestring += ' VBR'
        return 

also, the best way would probalby be to open an issue at beets, asking for a field for the items

or, create our own field by somehow reading file properties

Schweinepriester commented 9 years ago

just started https://github.com/Schweinepriester/beets-printimport - a first version is working already (without bitrate though)

maybe we can have our "custom string" as entry for album_fields, resulting in the possibilty to use both, the plugin and beet ls -a with the same string