Setting Play Count in Music app

The main question remains is : what is your playlist “Play Count Util”. It is some downloaded playlist or something other? And, are you sure it is not downloaded to Music library? Because when I try to read play count of free URL track, it has not Get Info either.

If you don’t clarify the situation and the user with a paid account in the iTunes Store does not appear, you are unlikely to be provided with assistance in obtaining a working solution.

Start by believing that the Doug’s app doesn’t do magic that can’t be repeated. One thing is for sure: it is paid, as well as iTunes Store.

and,

It already is or it already was? And what it IS or WAS, ON or OFF? It is fully unclear for other users, and leads them away from understanding the problem and solving it.

I will make it clear and understandable:

[format]Go Safari–>Preferences–>Reader, set “Automatically use Reader” on mascripter.net to ON[/format]
, and you have problems when trying publish post on mascripter.net

[format]Go Safari–>Preferences–>Reader, set “Automatically use Reader” on mascripter.net to OFF[/format]
, and you publish post on mascripter.net without problems

Yes, good question. It’s a Smart Playlist that shows all of the files in the Go Through playlist that don’t have a play count of zero.

iTunes Screenshot

I’m not sure what the iTunes Store has to do with this issue.

That’s exactly where I started, and why I’m harping on this. if Doug’s script can do it, there’s a way to do it. If our script doesn’t do what Doug’s can, we’re doing something wrong.

Come to think of it, perhaps the place to start is to try to replicate Doug’s script, and go from there. That way, nothing in my personal setup could be the problem.

Neither is true. It’s not paid, though donations are appreciated. And it is not iTunes Store, but freely downloadable from his site. It’s just a compiled, protected AppleScript.

If I had just then done it, I wouldn’t have said “it already is.” That seems pretty unambiguous to me. “It’s already the way you suggest.” But sure, it already was off before any of this started.

I don’t think you understand the problem. The problem is that I tried to post twice within 60 seconds, and it wouldn’t let me. But even that isn’t the problem; that’s just part of the design of the system. The problem is that it said “%s” instead of “60s” in the error message.

Okay, let’s leave the hocus pocus with Safari Reader alone. Let’s assume that I misunderstood you.

Finally, I managed to find out from you that you are working with smart-playlist, which is also uploaded to iCloud.

Now, it remains to find out which version of OS X you are working with. Because then you had “Operating System: macOS 10.14”, then you declare that “he above says” macOS 10.14, “but I’m using 10.15.”, But now under the rest of the posts the information is completely erased.

Also, It seems to me that I need to pull out information from you about the version of iTunes.app with pliers. No, I do not intend to do this anymore, as it is tiresome. You have already been answered by a more experienced user than me.

No, the smart playlist is not uploaded to iCloud; smart playlists which reference other smart playlists are not iCloud-compatible.

I’m running Catalina, 10.15.7.

I don’t recall you or anyone asking this before. My iTunes version is Music 1.0.6.10.

My current question is: Can anyone replicate the New Play Count functionality?

Model: MacBook Pro 2015
AppleScript: 2.7
Browser: Safari 605.1.15
Operating System: macOS 10.15

@Calion, hello.

You very well provided a screenshot of the “Play Count Util” playlist. Do you see those clouds with an arrow pointing down next to every song? They mean these songs are in iCloud. Now all that remains is to read the bug note posted by @technomorph. Or download the songs to your computer, reset play counts and upload them back to iCloud. If Apple hasn’t fixed this bug yet.

It’s hard to understand why the official New Play Count.app page still reminds you that the app doesn’t work with iCloud songs, and you claim it does. I think you better ask the Apple about how your problem is being solved.

Yes, the songs are in iCloud. But the playlists in question are not.

This bug is irrelevant to this situation. a) I’ve been subject to this bug for years; it doesn’t prevent AppleScript from changing the play count at all; it just means that it doesn’t “take” on a permanent basis. I’ve learned to deal with it, but it doesn’t affect the script in question (and, by the way, is unaffected, in my experience, by whether the song is downloaded to my machine. If it’s in iCloud at all—whether downloaded or not—this can happen). b) Doug’s New Play Count script works just fine on exactly these songs in exactly this playlist. So the problem can’t be some iCloud bug; it must be that we aren’t getting the script right.

The New Play Count.app page does not at all say that the app doesn’t work with iCloud songs. It just notifies the user of a potential bug that will cause play counts to spontaneously revert. My problem isn’t that the play counts are spontaneously reverting after they’re reset. My problem is that the play counts aren’t resetting—with any script I’ve been able to create—in the first place. Doug’s Script—and doing it manually—works just fine.

Hi. I don’t have anything later than Mojave installed, but perhaps you could test this.

tell application "iTunes"
	tell (playlist "Enya"'s tracks whose kind contains "audio" and location is not missing value)
		set unplayed to 1
		tracks's played count
	end tell
end tell

The Doug’s Script isn’t script but Doug’s Application. Assuming it works as you say, try to save my script in post #6 as application. If it will ask for some permissions, grant them. If it will work in application form, then the bug is related to script form. You can then solve this bug granting the same permissions to your Script Editor. Or, you can’t.

Once I change “iTunes” to “Music,” I get an error on run: "Music got an error: Unknown object type.” The word “unplayed” is selected, so I assume that “unplayed” is an unknown object type in Music.

That didn’t help. However, I did manage to get it working, although without any error-checking or anything, as that’s beyond my current skill level:

tell application "Music"
	repeat with t in (get tracks of playlist "Play Count Util")
		set the played count of t to 0
	end repeat
	set shuffle enabled to false
	play playlist "Go Through"
end tell

I…don’t know what in your script isn’t working, but at least we now know that it’s possible.

Now this is difficult to establish, so you threw out the check for the track class and the check for the fact that the play count is already = 0. Apparently, you are indifferent to debugging the script line by line and familiarizing users with the thrown error. If at all this error has ever been thrown. Because everything worked for me already starting from post # 6. I will remember you as a user with whom it is better not to communicate anymore. To preserve nerve cells.

Read the posting guidelines again and try to control your urge to attack other posters. If you’re not getting anywhere with them, simply stop replying.

I am very, very, very confused.

I’ve established that this is possible. I’ve found the basic problem. I tried to put my change back into your script, but it didn’t work. So there’s something wrong here that I don’t know what it is. I don’t know how to debug line by line if I can’t get the original script to work at all. Should I just throw random lines from your script in and see if they fail? That seems like a futile task. I was hoping that the information I gave would shed light on the problem.

I think you’re expecting me to know AppleScript well, but if I did, I probably wouldn’t need to have posted this problem.

Hi. Debugging line by line is more or less how you have to explore otherwise inexplicable errors. Whether new or old to scripting, it’s essential that you have feedback, so you should view the event log; click on the far right icon on the Script Editor’s window’s bottom with ‘Events’ or ‘Replies’ selected in the bar above it. What is the result from this?

tell application "iTunes"
	tell playlist "Play Count Util"'s tracks 1 thru 5 to try --adjust arbitrary number as needed for representative sample 
		unplayed
	on error err
		{played count, kind, its class, location, err}
	end try
end tell

tell application “Music”
get unplayed of tracks 1 thru 5 of playlist “Play Count Util”
→ {false, false, false, false, false}
end tell
Result:
{false, false, false, false, false}

And this?

tell application "iTunes"
   tell playlist "Play Count Util"'s tracks 1 thru 5
		try
			set unplayed to 1
			return unplayed
		end try
		try
			set played count to 0
		on error
			beep 3
		end try
		{unplayed, played count}
	end tell
end tell

tell application “Music”
set unplayed of tracks 1 thru 5 of playlist “Play Count Util” to 1
→ {current application, current application, current application, current application, current application}
get unplayed of tracks 1 thru 5 of playlist “Play Count Util”
→ {true, true, true, true, true}
end tell
Result:
{true, true, true, true, true}

Those results demonstrate a change took place in the unplayed property; by definition, those tracks should have a zero play count, so you can extend this idea to attempt to change all the tracks in that playlist or continue to experiment with testing their played count, kind, class, and location properties to see if there’s some reason why some are settable but others are not.

I know this is an old thread, but just for the record I think the very first script will work if you amend this line:

if class of t is file track or class of t is URL track then

to this:

if class of t is file track or class of t is URL track or class of t is shared track then

The “shared track” class refers to tracks stored in Apple Music or iCloud, hence why your original script would only change the play counts of downloaded files.

Hope this helps either the OP or anyone else.

1 Like

Yes! That’s exactly the kind of answer I was looking for! Thanks!