• Home
  • Blog
  • Add-ons
  • Forum
  • Wiki
  • Developers
Nightingale - The tune of life, the tune of yours
  • Portal
  • Search
  • Member List
  • Calendar
  • Help
  • Portal
  • Search
  • Member List
  • Calendar
  • Help
Guest Hi, Guest
  • Login
  • Register
Login
Username:
Password: Lost Password?
 
Nightingale Forums Nightingale General Discussion reset Play count

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Thread Modes
reset Play count
tonyd Offline
Junior Member
**
Posts: 5
Threads: 2
Joined: Jun 2015
Reputation: 0
#1
10-19-2015, 11:52 PM
How do you reset the play count in nightingale 1.12.1 ?
Find
Reply
rsjtdrjgfuzkfg Offline
Developer
*******
Posts: 664
Threads: 15
Joined: Oct 2011
Reputation: 15
#2
10-21-2015, 12:18 AM
I'm not aware of a direct way to do so in the graphical user interface.

Thus, you can either write an add-on wiping the play count (have a look at RatingFile's source code, it uses the same APIs), use RatingFile to back your ratings and play/skip counts up, then edit the resulting file (it is a regular text file, any editor with a search-replace feature should work), and import it again, or directly modify the sqlite database located in your profile's 'db' folder.

Did that already help you? If not, what OS are you on (windows / linux / mac)?
Songbird/Nightingale Community Developer and German Translator
Find
Reply
tonyd Offline
Junior Member
**
Posts: 5
Threads: 2
Joined: Jun 2015
Reputation: 0
#3
10-21-2015, 05:40 PM
(10-21-2015, 12:18 AM)rsjtdrjgfuzkfg Wrote: I'm not aware of a direct way to do so in the graphical user interface.

Thus, you can either write an add-on wiping the play count (have a look at RatingFile's source code, it uses the same APIs), use RatingFile to back your ratings and play/skip counts up, then edit the resulting file (it is a regular text file, any editor with a search-replace feature should work), and import it again, or directly modify the sqlite database located in your profile's 'db' folder.

Did that already help you? If not, what OS are you on (windows / linux / mac)?

Hi
I am on Linux

I had a quick look at the db with sql lite but I could not see the field for play counts and the db did not seem to contain enough entries for the amount of files I have

do you know the details of the db ?

cheers
Find
Reply
rsjtdrjgfuzkfg Offline
Developer
*******
Posts: 664
Threads: 15
Joined: Oct 2011
Reputation: 15
#4
10-22-2015, 12:46 AM (This post was last modified: 10-22-2015, 12:51 AM by rsjtdrjgfuzkfg.)
Warning: Long answer. Read till the end (or only the end for that matter) to get a reasonable solution to reset play counts.

(10-21-2015, 05:40 PM)tonyd Wrote: I had a quick look at the db with sql lite but I could not see the field for play counts and the db did not seem to contain enough entries for the amount of files I have

do you know the details of the db ?

First of all, did you open the database of your main library? You are most likely interested in ~/.nightingale/XXXXXXXX.default/db/main@library.songbirdnest.com.db

To get the play counts, first determine the property_id of play counts in your database (through the table properties), then update the play counts themselves in the resource_properties table. In theory, the following should work:
Code:
UPDATE resource_properties SET obj = '0', obj_searchable = '+0000000000000000000', obj_sortable = '+0000000000000000000' WHERE property_id = (SELECT property_id FROM properties WHERE property_name = 'http://songbirdnest.com/data/1.0#playCount');
The issue is, that the sqlite command line interface does not know about Nightingale's collation types, and thus would respond to the above query with "Error: no such collation sequence: library_collate". Sorry, I did not think about that when suggesting performing the change on a db-level.

It would, in theory, be possible to build only the collation type into a library and load it via ".load", but the collation type is dependent on the whole localization code (as it is dependent on Nightingale's current locale, see components/dbengine/src/DatabaseEngine.cpp), and must not be changed without issuing a migration step, so using a quick and dirty fixed-locale collation might break indices for libraries not created in that locale. I think it would be possible to force collation migration to simple c-style comparasions when switching localeCollationEnabled on the DatabaseEngine to false, however I have not verified that, so don't blindly assume that works (and you'd still need to build a collation library for the sqlite cli).

You can, however execute SQL directly through Nightingale. To reset play counts, back your profile up (as you should when messing with the internals of your library), and execute the following in the error console (tools menu, copy-paste in the small text field and hit evaluate) After "Done. Remember to immediately restart Nightingale" is printed, restart Nightingale without doing anything else, as caches might be outdated. After you restarted, your play counts are all resetted:
Code:
var dbq = Components.classes["@songbirdnest.com/Songbird/DatabaseQuery;1"].createInstance(Components.interfaces.sbIDatabaseQuery);
dbq.setDatabaseGUID("main@library.songbirdnest.com");
dbq.addQuery("UPDATE resource_properties SET obj = '0', obj_searchable = '+0000000000000000000', obj_sortable = '+0000000000000000000' WHERE property_id = (SELECT property_id FROM properties WHERE property_name = 'http://songbirdnest.com/data/1.0#playCount');");
dbq.execute();
dbq.waitForCompletion();
"Done. Remember to immediately restart Nightingale!"


So much about the database, but read on for a better alternative I have not thought of before: instead of writing an add-on properly resetting the play counts, you can also do so through the error console: main advantage is that you do not run into caching issues, and this works independently of the structure of the database:
Code:
Components.utils.import("resource://app/jsmodules/sbProperties.jsm");
var sbILibraryManager = Components.classes["@songbirdnest.com/Songbird/library/Manager;1"].getService(Components.interfaces.sbILibraryManager);
var mainLibrary = sbILibraryManager.mainLibrary.QueryInterface(Components.interfaces.sbIMediaList);
for (var i = 0; i < mainLibrary.length; i++) {
  var item = mainLibrary.getItemByIndex(i);
  if (item.getProperty(SBProperties.isReadOnly) || item.getProperty(SBProperties.trackName) === null) {
    continue;
  }
  item.setProperty(SBProperties.playCount, 0);
}
"Done."
This is probably the best way.
Songbird/Nightingale Community Developer and German Translator
Find
Reply
« Next Oldest | Next Newest »


  • View a Printable Version
  • Subscribe to this thread
Forum Jump:


Users browsing this thread: 1 Guest(s)
  • Return to Top
  • Lite (Archive) Mode
  • RSS Syndication
Current time: 03-27-2023, 01:38 AM Powered By MyBB, © 2002-2023 MyBB Group.
Design By AliReza_Tofighi In WhiteCrow Software Group.
white outlined nightingale project logo

Nightingale is free!
It is an Open Source project released under the terms of the GNU General Public License v2 (GPL v2).
For more details, please read the license information.

Follow us!
f  g  t

Support
  • Community Forum
  • Official Blog
  • Add-ons
  • Wiki
  • Help Forum
Contribute
  • Developer's Center
  • Translate Nightingale
  • Source Code
  • Report a Bug
Ressources
  • Download Nightingale
Linear Mode
Threaded Mode