Welcome, Guest
Python Scripts for ComicRack
  • Page:
  • 1
  • 2

TOPIC: [Beta Script] StorePlus V0.1 - Saves non stored fields in books

[Beta Script] StorePlus V0.1 - Saves non stored fields in books 7 months 4 days ago #50729

  • Xelloss
  • Xelloss's Avatar
  • Offline
  • Platinum Boarder
  • Posts: 614
  • Thank you received: 187
  • Karma: 37
Ok, I have been working in this script the last few days... It is still a long way to go for it to be released as a complete script, but I wanted to share with you what I have done till now...

It is a simple script, based in many ones I have seen around the forum... It saves fields that ComicRack doesn't store in comic book files, but that it does in the database... The idea is not new, it saves it as text in the notes field (which is saved then inside the book), but I am trying to add there as many data in the database as I can find...

For now the fields saved are the following ones:

HasBeenRead: If the comic has been read or not
CurrentPage: The last page opened and the one you open it gain if you use that option
LastPageRead: The last page read in the comic
OpenedCount: How many times the comic has been read
OpenedTime: When was the comic last opened
Released: Comic released day
Rating: Your rating of the comic
CommunityRating: The community rating
Tags: All tags
Review: The Review text
SeriesComplete: The Series is Complete field
BookAge: The Catalog Field
BookCondition: The Catalog Field
BookStore: The Catalog Field
BookOwner: The Catalog Field
BookCollectionStatus: The Catalog Field
BookNotes: The Catalog Field
BookLocation: The Catalog Field
ISBN: The Catalog Field
CustomValuesStore: All custom fields

As you can see the idea is to be able to delete a comic of the library and add it again without losing ANY data from the book in the database... (or just readd them in another library without losing any infomartion)

Some fields such as Added date and FilePath are not stored for obvious reasons...

How to use it: Just select one or more books with the data already complete in them, go to Automation, and select "Save Data". This will add a text in the book notes with all the data. For it to be really saved in the book file you have to have it set to store the notes field of course (and update if needed after Saving). The text will overwrite any other version of other data saved by this script before, BUT not any other text you put in the notes by yourself (for example comicvine scraper text)....

For Loading the data, select the comics you want to load the data you already saved... and go to Automation, and select "Load Data". This will overwrite all the saved fields to the ones you had in the book when you last saved them... (remember it will overwrite the saved fields even if they are not empty!)

As I mentioned in the name of the topic, this script is by far not finished... This is an Alpha version for tester to test it... and post bugs, changes they would like, fields/data I forget you would like added to the script, etc, etc, etc... Any Ideas are welcomed!

AGAIN: this script is not fully developed yet, don't use it in more than one or a two books, use it under your own risk, and only use it to test how it works. The are still a lot of bugs to be fixed, and your data in those books can be lost forever because of those bugs

To install it, as a way of keeping non developers out of this script untill I finished fixing major bugs, copy the .py file into your script folder... and restart ComicRack (of course final versions will include an installer)

Note: Cosmetic things as icons and good menun names are to be added in the future...

Updated: First Beta (0.1)

File Attachment:

File Name: StorePlus-2.crplugin
File Size:2 KB
Last Edit: 2 months 4 weeks ago by Xelloss.
The administrator has disabled public write access.
The following user(s) said Thank You: perezmu, rmagere

[Alpha Version Script] StorePlus V0.1 - Saves non stored fields in books 7 months 3 days ago #50730

  • rmagere
  • rmagere's Avatar
  • Offline
  • Gold Boarder
  • Posts: 282
  • Thank you received: 33
  • Karma: 8
Looks interesting (as per other thread ;) )

Couple of questions:

1) Out of curiosity how are existing notes handled?
E.g. I have saved in my notes section "Amazing comic - read it on a beach when I was 5 and daydreamed of being an astronaut"
What happens to that note between "Save Data" and "Load Data"?

2)Will there be a way to identify out-of-date notes? E.g. "Current Page = 10"; I save the data; then I read more and arrive to Page 20. Is there a way to identify those comics for which the "saved data" does not match the data in the database - a bit like "files to be updated" are currently identified?

As always thank you for your work on all your scripts.
The administrator has disabled public write access.
The following user(s) said Thank You: Xelloss

[Alpha Version Script] StorePlus V0.1 - Saves non stored fields in books 7 months 3 days ago #50731

  • Xelloss
  • Xelloss's Avatar
  • Offline
  • Platinum Boarder
  • Posts: 614
  • Thank you received: 187
  • Karma: 37
1) as it is said above, it should not modify existing notes (the coded data is always added after the user notes)

2) mmmh, I like your idea, let me think about that...
The administrator has disabled public write access.

[Alpha Version Script] StorePlus V0.1 - Saves non stored fields in books 7 months 3 days ago #50732

  • rmagere
  • rmagere's Avatar
  • Offline
  • Gold Boarder
  • Posts: 282
  • Thank you received: 33
  • Karma: 8
Xelloss wrote:
1) as it is said above, it should not modify existing notes (the coded data is always added after the user notes)

You are correct - the part I am confused with and did not make clear is: are there rules for it not to impact the notes? [not having tried the script and not having my comicrack accessible at the moment I cannot test].

E.g.

Before Save Data
"random text
"

After Save Data
"random text"
variable 1 [as stored by script]

Now I want to modify the note text: should I always modify above where the variable 1 text is stored? Can I modify anywhere and have:
"random text"
variable 1
"random text 2"
i.e. are there any watch outs on how the note field is edited and modified after having been interacted with by the script.
The administrator has disabled public write access.

[Alpha Version Script] StorePlus V0.1 - Saves non stored fields in books 7 months 3 days ago #50733

  • Xelloss
  • Xelloss's Avatar
  • Offline
  • Platinum Boarder
  • Posts: 614
  • Thank you received: 187
  • Karma: 37
The data is stored between <data> and </data>, and when you save, before adding the new data, it deletes all that is between those markers... (it is supposed this will be found only once per notes, if there are more only the first one would be deleted)

So image this steps:

1- Your Text 1

- You save

2- Your Text 1
Data

- You add more text

3- Your Text 1
Data
Your Text 2

- You save again (deleting the previous data and adding the new one)

4- Your Text 1
Your Text 2
New Data

While you don't change what is between the markers, your text should not be modified (at least in theory) and the new Data is always stored at the end of the notes... (of course never use the markers in your text as it would make the script crazy and unpredictible to what it would do XD)

Notice you can edit your texts (1 or 2) and that will also be untouched by the script. Also the data doesn't have to be in the end to be read... so if in step 3 you Load the data, there will be no problem at all.

Also, as the data is coded in XMLish kind of way (not real XML but it is similar) you can even edit the data yourself manually easily if you want, I "coded" it in a way it is very intuitive to understand...

About the other thing, of taking notice of what data is not up to date... As I cannot have control over changes in Comicrack (and I think it is not possible to do in a script) I cannot make it so when you edit somehing the system knows it is not up to date, as it happens with updates... What I can do is a smartlist script that compares the data in the comics and the data in the stored data for every comic... but it would be a lot of processing made for a smartlist script (any refresh would take the same amount of time it would take to store in memory- not harddisk - all your comics data in every comic note and more). I don't know if that is a good idea... For that just apply the save in every comic in your library and it will be the same...

What I CAN ADD, is an option that if you save data in a comic and the data is exactly the same, it doesn't change notes at all (no deleting and adding the same) so that it doesn't update the books notes, and so you only have to write to disk the ones modified... (That would be indeed a HUGE improvement... but a bit hard to code and bugfix, I will work on that when I have some free time XD)

Apart from that, I noticed, AS USUAL, my script is having problem with unicode values in fields... I have to take a look at that D:
Last Edit: 7 months 3 days ago by Xelloss.
The administrator has disabled public write access.
The following user(s) said Thank You: rmagere

[Alpha Version Script] StorePlus V0.1 - Saves non stored fields in books 7 months 1 day ago #50785

  • rmagere
  • rmagere's Avatar
  • Offline
  • Gold Boarder
  • Posts: 282
  • Thank you received: 33
  • Karma: 8
Xelloss wrote:
The data is stored between <data> and </data>,
[SKIPPED]
Also, as the data is coded in XMLish kind of way (not real XML but it is similar) you can even edit the data yourself manually easily if you want, I "coded" it in a way it is very intuitive to understand...

Thanks for the explanation - makes perfect sense and wonderfully answers the questions :)

Now excuse my quoting out of order the rest of the message:
Xelloss wrote:
What I CAN ADD, is an option that if you save data in a comic and the data is exactly the same, it doesn't change notes at all (no deleting and adding the same) so that it doesn't update the books notes, and so you only have to write to disk the ones modified... (That would be indeed a HUGE improvement... but a bit hard to code and bugfix, I will work on that when I have some free time XD)

That would be impressive

Xelloss wrote:
About the other thing, of taking notice of what data is not up to date... As I cannot have control over changes in Comicrack (and I think it is not possible to do in a script) I cannot make it so when you edit somehing the system knows it is not up to date, as it happens with updates... What I can do is a smartlist script that compares the data in the comics and the data in the stored data for every comic... but it would be a lot of processing made for a smartlist script (any refresh would take the same amount of time it would take to store in memory- not harddisk - all your comics data in every comic note and more). I don't know if that is a good idea... For that just apply the save in every comic in your library and it will be the same...

For this one I wonder if there is an easier solution.

E.g. could the script add a custom value called "DateNotesSaved" (or some such) then the smartlist only need to look at whether the Last Modified/Updated Date is different from the DateNotesSaved and therefore do a much simpler check than a full comparison of the information?
The administrator has disabled public write access.

[Alpha Version Script] StorePlus V0.1 - Saves non stored fields in books 7 months 1 day ago #50786

  • Xelloss
  • Xelloss's Avatar
  • Offline
  • Platinum Boarder
  • Posts: 614
  • Thank you received: 187
  • Karma: 37
I LOVED YOUR IDEA, let me have some free time at home and I will try to do something like that
The administrator has disabled public write access.

[Alpha Version Script] StorePlus V0.1 - Saves non stored fields in books 7 months 1 hour ago #50796

  • Xelloss
  • Xelloss's Avatar
  • Offline
  • Platinum Boarder
  • Posts: 614
  • Thank you received: 187
  • Karma: 37
Ok, been working on this...

I have already added the feature that only update the notes with the data when data is different... (it was much easier than I thought)

About the smartlist to find for modified data not stored... I tried for hours to find a value that says when the comic was last modified, and I couldn't find it. In the SQL database (or XML if you don't use SQL) there is an update counter that adds 1 every time you make ANY modification to the comic, BUT I couldn't access it from the CR API... (there must be a way but I couldn't find it)

All the same, I added a smartlist now that compare the data from books and the data from the stored code... It is a bit slow for a smartlist (it takes 1.5 seconds in my 24k comics), but it does the trick... You can use it inside a folder so that you can only use the smartlist when you need and it doesn't lowdown your CR performance...

Another difference: Now when you update the code, the code will keep its order in relation to your text, and will not move to the end always as before... You can however move the code wherever you want in your code manually and it will continue loading it ok (this is because now it replaces the previous code with the new one, and not delete the previous one and add the new in the end of the notes as before)

New alpha version:

File Attachment:

File Name: StorePlus-2.zip
File Size:2 KB
The administrator has disabled public write access.

[Alpha Version Script] StorePlus V0.1 - Saves non stored fields in books 6 months 4 weeks ago #50797

  • rmagere
  • rmagere's Avatar
  • Offline
  • Gold Boarder
  • Posts: 282
  • Thank you received: 33
  • Karma: 8
Cool :)

What about the variable "File Modified"? (I use it in a smartlist to find files I have touched in the last x number of days)

It would not be as exact as your smartlist (as I guess variables that have no impact on the comicinfo.xml will lead to no modification of files) but could be an early proxy before using the full smartlist (thinking of my 40k library)

Another question: how does the script handle custom fields? E.g. I have a custom field called "Processed" which I manually mark "Yes" when I have taken all the actions I need on a file and I am happy with it (e.g. run datamanager, set languages, etc) - is that field automatically exported as well?

Will be back at home next week - hope to give this script a spin then :)
The administrator has disabled public write access.

[Alpha Version Script] StorePlus V0.1 - Saves non stored fields in books 5 months 4 weeks ago #51619

  • Xelloss
  • Xelloss's Avatar
  • Offline
  • Platinum Boarder
  • Posts: 614
  • Thank you received: 187
  • Karma: 37
I have not answered your post because I couldn't use the forum for weeks... till now, that I am using some proxy (weird error)

About modified date, it wouldn't work, as you say, files are modified when fields with writtable data is changed, and only after update...

All the same I have worked in a smartlist that quickly looks for changes and it seems to work ok ( I have been using it for weeks now). It is a bit slow, but it takes about half a second or less to search in all my 30k library to find for not stored data.... Just use this smartlist in a on/off folder and it will work ok :)

About custom fields, it store ALL custom values as they are in the comic with the current values... (it just store the complete custom values data of the comic)
The administrator has disabled public write access.
  • Page:
  • 1
  • 2
Time to create page: 0.284 seconds

Who's Online

We have 122 guests and one member online