alexander-pick / MKMTool

MKMTool ist a helper application I wrote for tinkering around with optimization of sale processes on magiccardmarket.eu and the idea of automisation of some tasks most people wouldn’t be able to get done by pure manpower.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Updating prices of only part of inventory

haRPyMTG opened this issue · comments

Hello, first of all, the tool is amazing, but I ran into a problem. I'm a private seller on MKM, but I have more then 6k unique offers, so when i update my prices the list doesn't get finished, is there a way I can still use this tool, like, update half of the inventory on day 1, the rest on day 2 of something like that (excuse me if this has already been explained somewhere, I couldn't find anything).

I hope to hear from you soon.

Hi,
the "do half one day, second half other day" is theoretically possible, but currently not implemented.

It is actually really easy to implement, the code kind of already supports that, but somebody would have to do a user interface for it. I won't have the time to do it any time soon. But here are "instructions", perhaps if you are capable of compiling from source you can do changes in code yourself and just change one number every other day and recompile (MKMTool is small, so recompiling it takes no time):

It is all in MKMBot.cs, lines 471 to 486:

        var start = 1;
        // load file with lowest prices
        Dictionary<string, List<MKMMetaCard>> myStock = LoadMyStock();
        try
        {
            do
            {
                var doc = MKMInteract.RequestHelper.readStock(start);

                result = doc.GetElementsByTagName("article");
                foreach (XmlNode article in result)
                {
                    articles.Add(article);
                }
                start += result.Count;
            } while (result.Count == 100);
        }

The stock is read in batches of 100 (MKM does not allow to read more at once). The "start" variable says which is the first article from your inventory to read, so basically we start at the beginning of our inventory (start = 1), read 100 articles, increase "start" by 100 and do the same call again, now starting reading from our 101st article etc. And that continues until there is something to read (while results.Count == 100, i.e. if we read less than 100 in one call, we know there aren't any more). So instead of starting at 1, we could start at some user provided number - one day you would start from 1, the other from 3001 (or 3501 or other, depending on how many exactly you have), skipping the first half of your inventory.
To read only half, you would introduce one extra variable, let's call it maxArticles. It would say how many articles to read at most. In your case, you could set it to 3000. The terminating condition would then change to end when either there are no more articles to read, or if maxArticles was processed. So the final code would look like this - only the first (two) and last line is different:

        var start = 1; // change to 3001 to skip first half of your stock
        var maxArticles = 3000;
        // load file with lowest prices
        Dictionary<string, List<MKMMetaCard>> myStock = LoadMyStock();
        try
        {
            do
            {
                var doc = MKMInteract.RequestHelper.readStock(start);

                result = doc.GetElementsByTagName("article");
                foreach (XmlNode article in result)
                {
                    articles.Add(article);
                }
                start += result.Count;
            } while (result.Count == 100 && articles.Count < maxArticles); // while the full reading capacity was reached AND we have less than max articles so far
        }

I haven't tested it but I am pretty sure it works. I think even if you don't understand coding you can just download Visual Studio and MKMTool's source code, open the MKMBot.cs file, copy paste this code over the current one and just "hit play" (F5) and just don't forget to switch the "start" every day between 1 and 3001.

If you don't want to modify the code, a possible workaround is to run the update around the time MKM is resetting the requests counter. I think it's midnight CET, but I'm not sure - try starting the update at 23:58 and observe the requests counter at the bottom of MKMTool, it should reset at some point. In theory if you get the timing right, you could do this every other day to update some portion of your stock before midnight and some after. But it might not work at all, I don't know how precise the resetting is.

NICE! I will test this tomorrow and will let you know!

So i edited the source code, but how do I run the program now? If I hit f5 a screen comes up that i need to select a file to run, but there is no file selectable, how do I now start the edited MKMTOOL? (sorry, this is not really my area of knowledge).

I am guessing you did not open the MKMTool.sln file. It should have the visual studio icon, just double click it, it will open in visual studio, than the F5 should just work, with no dialogue.

Im a n00b, I know, when I try what you say, i get this screen:
https://gyazo.com/72f58786c37a50127df5ff7cca84516a
When I press no I get these errors:
https://gyazo.com/5b17f8a4f29735295370219b960e889f
When I press yes I get this erros:
https://gyazo.com/d415d8c2df5ec7ac95c00dc7a34af5b7

Never seen those, but it looks like the solution is simple, it's just some security mechanism:

https://stackoverflow.com/questions/51348919/couldnt-process-file-resx-due-to-its-being-in-the-internet-or-restricted-zone-o

Nice! that worked, but now im getting this error:
https://gyazo.com/5ed6b64db49b416023ed4d586356f7a0
(I followed the steps like adding the tokens and removing the _template from the name, or was that wrong?)

Don't change the config_template.xml in MKMTool-master\MKMTool, change it in MKMTool-master\MKMTool\bin\Debug\ edit: the edited file also needs to be in MKMTool-master\MKMTool, see posts below

Basically, the bin\Debug\ is the folder that will have your compiled version of the program, i.e. the actual .exe file and all the other necessarry files like the config file. What the "F5" does is it compiles the source files (in MKMTool-master\MKMTool), puts the result to MKMTool-master\MKMTool\bin\Debug and then runs the MKMTool-master\MKMTool\bin\Debug\MKMTool.exe just like you would normally run it by double clicking it.

ugh, Im so sorry for being such a pain in the ass, but I cant see a bin folder there?

It should be created once you compile. In the error message you posted before ( https://gyazo.com/d415d8c2df5ec7ac95c00dc7a34af5b7) it shows the path C:\users\Rick post\Desktop\MKMMASTER\MKMTool-master\MKMTool\bin\Debug

In summary, the steps should be:

  1. Download the MKMTool source, unzip (that seems to be OK)
  2. Open MKMTool.sln (in visual studio).
  3. Do not modify any files except for the MKMBot.cs to do the change you want.
  4. Press F5. MKMTool should start after a minute and immediately crash because it can't find config.xml, but that's OK.
  5. Go to ....\MKMTool\bin\Debug, config_template.xml should be there. Rename it to config.xml and fill in your credentials.
  6. Press F5 in visual studio again, now it should work

I followed all the steps, after i change it in step 5, i run it again, but then i get the error message again (https://gyazo.com/c2bd1274b47075370478d04d4cb79b57)
When i look in the bin folder, i see that the config_template.xml is there again, with the other made config file
https://gyazo.com/275abd3171e3c4985a7590f473529aec
What am I missing?

Ah, my bad, didn't realize it wants both at both places. Just copy the config.xml you created in the bin folder to the ...\MKMTool-master\MKMTool, so you will have both config and config_template everywhere...maybe then it will stop complaining.

OMG, IT WORKED, the code to, no good numbers to back it up, because the request count got reset (midnight xD), but before the reset it was around 2k, after the reset it is 2064, I added a max on 4000 cards, so it looks like it works, I wanne thank you so much for all the help, this is amazing!

Version 0.8. is now out, this feature is still not there, but there are instructions in the code what to easily change to set the limits: in MKMBot.cs, just change lines 654 from #if false to #if true and then set the two limits (startFrom and batchSize) to whatever number you need.

From 0.8.2.0, commit ccac8c8, MKMTool supports starting Price Update from where it last finished. You can also interrupt it at any time by pressing the price update button again. You cannot specify the "batch" size, it will simply run until you stop or run out of API requests, but the next day you can continue where you ended. More info in documentation https://github.com/alexander-pick/MKMTool#Price-Update.
So if you are one of the people with access to the API you can benefit from this.