Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Last.fm Playcount Sync through Python and foo_customdb (Read 4741 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Last.fm Playcount Sync through Python and foo_customdb

After the demise of the previous attempt, I've devised a new method for tracking plays in Foobar. It's complicated to set up, but works flawlessly afterwards. It's built on the foundations marc2003 created, using beets and foo_customdb to display the play counts.

Requirements:
    foo_customdb
    Python 2.7
    pip
    beets

Instructions:
  • Download foo_customdb from here or from the attached file below.
  • Install like normal.
  • NOTE: If you had installed marc2003's software, you can skip this next step.
  • Within fb2k, open the Custom DB Preferences page. Within "Fields", click Add, and then write within both Display and Name: "LASTFM_PLAYCOUNT_DB". Select "Custom" for Key and write within, "$crc32($lower(%artist%%title%))".
  • Make note of the path to the database on the Database page. Mine is, "C:\Users\Noah\AppData\Roaming\foobar2000\customdb_sqlite.db"
  • Go to the Python downloads page and follow the instructions on install the latest version of Python 2.7 (2.7.11 currently)
  • NOTE: On the "Customize Python 2.7" dialog, make sure you select "Add python.exe to Path"
  • Verify pip in installed: open a cmd or powershell window and type, "pip -V"
  • If it returns an error such as, "The term 'pip' is not recognized as the name of a cmdlet, function, script file, or operable program.", you have messed up. Go here and follow the instructions on that page to install it.
  • Otherwise, it should spit out, "pip 7.1.2 from c:\python27\lib\site-packages (python 2.7)" which means it's correctly installed.
  • With pip installed, type into a command prompt (cmd.exe or powershell), "pip install --upgrade beets". This will install and upgrade all necessary components needed to run beets and then install beets.
  • Once beets is installed, type into a command prompt, "beet config -e". This will open a text editor. Write (filling in the gaps with your own information):
Code: [Select]
plugins: lastexport
lastfm:
    user: [your last.fm username here]
    sqlite3_custom_db: [the noted location of your foo_customdb database as above]
  • Save and exit that file.
  • Now that beets is configured, download/save this file as "lastexport.py" in your beetsplug folder, which should be somewhere near "C:\Python27\Lib\site-packages\beets". That folder should contain a slew of wonderful plugins, and this one will fit right in.
  • Finally, after all that prep is done, type into a command prompt, "beet lastexport". It should quickly download and update all of your playcounts. This is what you'll be typing every time you want to update your playcounts.

Kind of complicated, I know, but a breeze once you get used to it. beets is magical and what I use to track and update all of the metadata info on my files behind foobar. Foobar is a near perfect player and interface for me, but it's not a great organizer, so I highly suggest beets if you feel frustrated by foobar's lackluster organizational support.

Please let me know if you have any questions or comments or pull requests! I'm very interested in making this better. (I'd honestly like to decouple it from beets, but beets is kind of magic, so I don't mind too much.)

Re: Last.fm Playcount Sync through Python and foo_customdb

Reply #1
I got this error :(

C:\WINDOWS\system32>beet lastexport
** error loading plugin lastexport:
Traceback (most recent call last):
  File "c:\python27\lib\site-packages\beets\plugins.py", line 255, in load_plugins
    namespace = __import__(modname, None, None)
  File "c:\python27\lib\site-packages\beetsplug\lastexport.py", line 18, in <module>
    import pylast
ImportError: No module named pylast

error: unknown command 'lastexport'

Re: Last.fm Playcount Sync through Python and foo_customdb

Reply #2
Oh crap! Okay, good to know. I forgot that beets requires pylast when touching Last.fm.

On the blank command line, type "pip install pylast". Close the window, and then reopen it and try "beet lastexport" again.

Re: Last.fm Playcount Sync through Python and foo_customdb

Reply #3
thank you very much ! it works

Re: Last.fm Playcount Sync through Python and foo_customdb

Reply #4
Thanks! I had been waiting for something like this to come around.

Re: Last.fm Playcount Sync through Python and foo_customdb

Reply #5
This is working great! I wonder if it can be customised to get more data from last.fm, like last played time?

Re: Last.fm Playcount Sync through Python and foo_customdb

Reply #6
Thank you! I'm very excited about this!

I'm stuck at "beet config -e" though.
It keeps saying 'failed to create process'
What coud be the problem?



Re: Last.fm Playcount Sync through Python and foo_customdb

Reply #9
(Bumping old post.)

I just wanted to say thanks. Just tried the tool--worked great!

 

Re: Last.fm Playcount Sync through Python and foo_customdb

Reply #10
Getting this error with latest Python (3.5)
Code: [Select]
Traceback (most recent call last):
  File "C:\Users\SKP\AppData\Local\Programs\Python\Python35\Scripts\beet-script.
py", line 11, in <module>
    load_entry_point('beets==1.4.5', 'console_scripts', 'beet')()
  File "c:\users\skp\appdata\local\programs\python\python35\lib\site-packages\be
ets\ui\__init__.py", line 1256, in main
    _raw_main(args)
  File "c:\users\skp\appdata\local\programs\python\python35\lib\site-packages\be
ets\ui\__init__.py", line 1243, in _raw_main
    subcommand.func(lib, suboptions, subargs)
  File "c:\users\skp\appdata\local\programs\python\python35\lib\site-packages\be
etsplug\lastexport.py", line 50, in func
    import_lastfm(lib, self._log)
  File "c:\users\skp\appdata\local\programs\python\python35\lib\site-packages\be
etsplug\lastexport.py", line 114, in import_lastfm
    user = config['lastfm']['user'].get(unicode)
NameError: name 'unicode' is not defined

Do I need to use Python 2.7 instead?

Re: Last.fm Playcount Sync through Python and foo_customdb

Reply #11

Getting this error with latest Python (3.5)
Code: [Select]
Traceback (most recent call last):
  File "C:\Users\SKP\AppData\Local\Programs\Python\Python35\Scripts\beet-script.
py", line 11, in <module>
    load_entry_point('beets==1.4.5', 'console_scripts', 'beet')()
  File "c:\users\skp\appdata\local\programs\python\python35\lib\site-packages\be
ets\ui\__init__.py", line 1256, in main
    _raw_main(args)
  File "c:\users\skp\appdata\local\programs\python\python35\lib\site-packages\be
ets\ui\__init__.py", line 1243, in _raw_main
    subcommand.func(lib, suboptions, subargs)
  File "c:\users\skp\appdata\local\programs\python\python35\lib\site-packages\be
etsplug\lastexport.py", line 50, in func
    import_lastfm(lib, self._log)
  File "c:\users\skp\appdata\local\programs\python\python35\lib\site-packages\be
etsplug\lastexport.py", line 114, in import_lastfm
    user = config['lastfm']['user'].get(unicode)
NameError: name 'unicode' is not defined

Do I need to use Python 2.7 instead?

The docs recommend Python 3.6 for the latest version 1.4.5.
http://beets.readthedocs.io/en/v1.4.5/guides/main.html#installing-on-windows

Re: Last.fm Playcount Sync through Python and foo_customdb

Reply #12
Thanks for the package!

I also had some problems with the beet config -e command and in the end I just edited the config.yaml file in the beets folder. Also the plugin wasn't recognised by beets until I moved it to the beetsplug folder instead of the beets folder.

Re: Last.fm Playcount Sync through Python and foo_customdb

Reply #13
Thank you a lot for this! It works as it states. The one thing I'm missing is a bit more precession, when matching, specifically in that album's aren't considered, so the same song on multiple albums, by the same artist, will all share the same playcount info.

Re: Last.fm Playcount Sync through Python and foo_customdb

Reply #14
Thank you a lot for this! It works as it states. The one thing I'm missing is a bit more precession, when matching, specifically in that album's aren't considered, so the same song on multiple albums, by the same artist, will all share the same playcount info.
You might want to look at foo_enhanced_playcount. Might do what you need, and does consider albums.