Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Schweinepriester opened this issue Jun 10, 2015 · 23 comments
Open

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

Schweinepriester opened this issue Jun 10, 2015 · 23 comments
Milestone

Comments

@Schweinepriester
Copy link
Owner

No description provided.

@Schweinepriester Schweinepriester changed the title plugin: beets-import-string plugin: beets-import-string!? Jun 10, 2015
@Schweinepriester Schweinepriester changed the title plugin: beets-import-string!? plugin: "beets-import-string"!? Jun 10, 2015
@zabelhaft
Copy link
Collaborator

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
Copy link
Collaborator

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
Copy link
Owner Author

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
Copy link
Owner Author

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

sofern das nicht schon mit existierendem funktioniert

@zabelhaft
Copy link
Collaborator

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
Copy link
Collaborator

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
Copy link
Collaborator

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

@Schweinepriester
Copy link
Owner Author

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
Copy link
Collaborator

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
Copy link
Collaborator

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

@Schweinepriester
Copy link
Owner Author

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
Copy link
Collaborator

  • is the definition of $bitrate in your config?
  • did you change the date in the snippet?
  • did you import anyhing?

@zabelhaft zabelhaft added this to the Raw import alpha0.1 milestone Jun 11, 2015
@Schweinepriester
Copy link
Owner Author

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

for the record, please post your output from beet config

@zabelhaft
Copy link
Collaborator

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

@Schweinepriester
Copy link
Owner Author

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
Copy link
Owner Author

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 added a commit that referenced this issue Jun 11, 2015
as mentioned in #3

first try, probably can be done better by using math instead of string operations
@Schweinepriester
Copy link
Owner Author

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
Copy link
Owner Author

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 :)

@zabelhaft zabelhaft modified the milestones: 0.0.2, 0.0.1 alpha Jun 11, 2015
@zabelhaft zabelhaft reopened this Jun 12, 2015
@Schweinepriester
Copy link
Owner Author

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
Copy link
Owner Author

for the future: implement VBR if album is VBR

@zabelhaft
Copy link
Collaborator

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
Copy link
Owner Author

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
Copy link
Owner Author

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

@Schweinepriester Schweinepriester modified the milestones: 0.0.2, 0.1.0 Jun 18, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants