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: Play count shared by same song on differnt albums? (Read 2082 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Play count shared by same song on differnt albums?

Is there any complement that allows for the play count to be updated in more than one instance of a song if it's found repeated in another album by the same artist (and having the same title)? For example if I listen to The Smiths - Panic from the album Rank, that the play count updates both that and The Smiths - Panic from the album The World Won't Listen? I'm currently using a script that fetches play count from last.fm and it does this, but I'm tired of the site so I wanna do the switch to offline play count and I don't want to lose this feature...

Play count shared by same song on differnt albums?

Reply #1
you could modify the WSH script so it bypasses last.fm and increments the play count by itself.

first you need to go to file>preferences>tools>custom database.
click on the action tab.
click add and then use the following settings:

Display: Customdb Add 1
Field: LASTFM_PLAYCOUNT_DB
Update: Contextmenu
Value: $add(1,$if2(%LASTFM_PLAYCOUNT_DB%,0))

now restart foobar before doing anything else.

now right click the WSH panel, find where it says..

Code: [Select]
function on_playback_time() {
    ps.playback_time();
}


replace it with

Code: [Select]
function on_playback_time() {
    ps.elapsed_time++;
    if (ps.elapsed_time == ps.target_time)
        fb.RunContextCommandWithMetadb("Customdb Add 1", p.metadb, 8);
}


now you're updating the playcount locally, there are no longer restrictions on the length of song or how much of it needs to be played before counting. if you want to change that, you go back in to the panel and find this...

Code: [Select]
function on_playback_new_track() {
    ps.playback_new_track();
}


replace it with

Code: [Select]
function on_playback_new_track() {
    ps.time_elapsed = 0; //do not edit this
    ps.target_time = Math.min(Math.floor(fb.PlaybackLength / 2), 240); //just edit this.
}


currently the target time is half the length or 4 minutes if the track is longer than 8 minutes. but now you're free to edit that however you like. just in case it isn't clear, the time must be specified in seconds.

Play count shared by same song on differnt albums?

Reply #2
Thank you very much for the detailed explanation and for still supporting your scripts!! I'm having trouble with this though, and I'm pretty sure I followed the steps properly:



Then I close foobar and...



As soon as I update function on_playback_time() { with the code you provided it stops working, and there is not even a message on the console regarding the play count script at all.

One more thing the code originally said:

Code: [Select]
function on_playback_time() {
//do not use fb.FoobarPath here as fb.ProfilePath already points to the same location if using portable mode
ps.cross_img = gdi.Image(fb.ProfilePath + "my_theme\\images\\cross.png");

    ps.playback_time();
}


so I moved

Code: [Select]
//do not use fb.FoobarPath here as fb.ProfilePath already points to the same location if using portable mode
ps.cross_img = gdi.Image(fb.ProfilePath + "my_theme\\images\\cross.png");


to another part of the script for it to be like you wrote it. I tried merging it with the updated code too, but none of these sorting methods had any effect on the play count working or not (well the line seems to be merely about an image anyway). Resulting script: http://pastebin.com/Su6pNUpa

Also wondering, in case this works will it consider tracks shorter than 30 seconds? and is there a way to make it tag the files? I searched for a way to do this and I tried the one in which you import settings with "Format from other fields..." but I think it imports the data held at that specific time, and doesn't update after that. I made sure they play count displayed is %LASTFM_PLAYCOUNT_DB% and not the $PLAY COUNT$ tag I generated with this method by the way so it's not that either...


Thanks again.

Play count shared by same song on differnt albums?

Reply #3
ah, it was a silly typo...

Code: [Select]
ps.time_elapsed = 0; //do not edit this


should have been

Code: [Select]
ps.elapsed_time = 0;


also, the bit that sets the image does not go inside the on_playback_time function.

http://pastebin.com/z0VgsaVH

it is possible to tag files with WSH panel mod but you realise it would only increment the playcount for that file and it wouldn't be shared across all files with the same artist/title tags in your collection? this is the opposite of what you asked for...

Play count shared by same song on differnt albums?

Reply #4
thanks more or less works now! the script crashes with short tracks though.

and i didnt know it would only choose one of the files, so im better off with a database. do you know if there is a simple way to "mark" played files though? the idea is that it's modified once played so i can sort it on windows by most recently modified, so i can know the most recent songs i've listened to. foobar/my pc has crashed many times and more often than not when it did i had many cached scrobbles that i lost, so then i have to guess what songs i listened to that day and manually scrobble them. this is one of the reasons why i wanted it local so that the playcounts are legit and not a guess (unless the crash will affect the database too?). maybe if i make it tag them as playcount just to mark them but display the database numbers for the actual playcount?

Play count shared by same song on differnt albums?

Reply #5
i can't see any reason why it would crash on short tracks. if you reported the error from the console it would help.... FWIW, the shortest track i have is 9 seconds and that worked fine.


Play count shared by same song on differnt albums?

Reply #6
yes sorry I didn't notice the console reported something:

Error: WSH Panel Mod (Last.fm Playcount Sync by marc2003): Microsoft JScript runtime error:
Invalid procedure call or argument
File: <main>
Ln: 22, Col: 9
<source text only available at compile time>
Audioscrobbler: Skipping track due to unsupported track length

I think it happens with tracks under 30 seconds.

Play count shared by same song on differnt albums?

Reply #7
try replacing....

Code: [Select]
function on_playback_time() {
    ps.elapsed_time++;
    if (ps.elapsed_time == ps.target_time)
        fb.RunContextCommandWithMetadb("Customdb Add 1", p.metadb, 8);
}

with
Code: [Select]
function on_playback_time() {
    ps.elapsed_time++;
    if (p.metadb && ps.elapsed_time == ps.target_time)
        fb.RunContextCommandWithMetadb("Customdb Add 1", p.metadb, 8);
}

Play count shared by same song on differnt albums?

Reply #8
yeah that doesn't crash thanks!

Play count shared by same song on differnt albums?

Reply #9
nevermind this post