andli / pymkm Goto Github PK
View Code? Open in Web Editor NEWPython wrapper for the cardmarket.com API. Also contains a working app with price updating of your personal stock, csv import etc.
License: MIT License
Python wrapper for the cardmarket.com API. Also contains a working app with price updating of your personal stock, csv import etc.
License: MIT License
Hi @andli, thanks for this nice tool. I have a small issue though:
From the docs I understood that the tool would use the trend price provided by the cardmarket.
I am using PyMKM 1.0.2 and recently ran an "Update stock prices" for the first time. Unfortunately, the minimum price that is set by the tool seems to be 0.25 cent, for all sorts of cards which is not really competitive, especially for non-foil commons with a trend price of e.g. 0.03 cent.
Could this be a bug or am I missing something?
I found a few niche cases of cards not working when imported from CSV. Names that are less than 4 characters long:
Fog,Seventh Edition,1,,English
And cards that have a "," in their name:
Inner Calm, Outer Strength,Saviors of Kamigawa,1,,English
Not worth fixing probably, as these cases are pretty rare. Just for your info :)
Hey there!
I just stumbled upon and tried out your tool for the first time, awesome work! I will thoroughly try it out over the next days :)
I noticed some very minor errors that i was able to fix by myself but i thought I'd let you know:
First I tried importing a CSV file (my main use case is importing lists created with Delver Lens. I got the following error:
I just included a static False in the get_price_for_product call, which fixed the issue.
For missing rarities I guess I can just add them in the config.json right? I would suggest adding all the missing rarities in the provided template for ease of use.
Best wishes!
Hello,
On a Windows 10 with Python 3.7.4, I got the error below when updating my stock price with custom rounding prices.
Traceback (most recent call last):
File "C:\Users\Romain\Desktop\pymkm-master - Copie\pymkm-master\pymkm_app.py", line 379, in get_rounding_limit_for_rarity
self.config['price_limit_by_rarity'][rarity.lower()])
KeyError: 'land'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File ".\main.py", line 19, in <module>
main()
File ".\main.py", line 15, in main
app.start()
File "C:\Users\Romain\Desktop\pymkm-master - Copie\pymkm-master\pymkm_app.py", line 71, in start
menu.show()
File "C:\Users\Romain\Desktop\pymkm-master - Copie\pymkm-master\micro_menu.py", line 34, in show
func(**kwargs)
File "C:\Users\Romain\Desktop\pymkm-master - Copie\pymkm-master\pymkmapi.py", line 25, in wrapper
return_value = func(*arg, **kwargs)
File "C:\Users\Romain\Desktop\pymkm-master - Copie\pymkm-master\pymkm_app.py", line 77, in update_stock_prices_to_trend
uploadable_json = self.calculate_new_prices_for_stock(api=self.api)
File "C:\Users\Romain\Desktop\pymkm-master - Copie\pymkm-master\pymkm_app.py", line 345, in calculate_new_prices_for_stock
article, api=self.api)
File "C:\Users\Romain\Desktop\pymkm-master - Copie\pymkm-master\pymkm_app.py", line 362, in get_price_for_single_article
article['idProduct'], article['product']['rarity'], article['isFoil'], language_id=article['language']['idLanguage'], api=self.api)
File "C:\Users\Romain\Desktop\pymkm-master - Copie\pymkm-master\pymkm_app.py", line 387, in get_price_for_product
rounding_limit = self.get_rounding_limit_for_rarity(rarity)
File "C:\Users\Romain\Desktop\pymkm-master - Copie\pymkm-master\pymkm_app.py", line 381, in get_rounding_limit_for_rarity
print(f"ERROR: Unknown rarity for {r}. Using default rounding.")
NameError: name 'r' is not defined
100% (1709 of 1709) |############################################################| Elapsed Time: 0:02:20 Time: 0:02:20
Best,
Romain
I got an error when importing card from list.csv
Action number: 7
Note the required format: Card, Set name, Quantity, Foil, Language (with header row).
Cards are added in condition NM.
N/A% (0 of 10) | | Elapsed Time: 0:00:00 ETA: --:--:--Traceback (most recent call last):
File "main.py", line 545, in
main()
File "main.py", line 89, in main
import_from_csv(api=api)
File "main.py", line 133, in import_from_csv
product_match[0]['idProduct'], foil, langauge_id, api)
File "C:\Users\CJ\Downloads\pymkm-master\pymkm.py", line 29, in call
return_value = self.function(*arg, **kwargs)
File "main.py", line 393, in _get_price_for_product
r = api.get_product(product_id)
AttributeError: 'int' object has no attribute 'get_product'
list.csv is :
Card,Set Name,Quantity,Foil,Language
brain pry,Dissension,1,,French
court hussar,Dissension,3,,French
flaring flame-kin,Dissension,1,,French
mistral charger,Dissension,1,,French
prahv, spires of order,Dissension,2,,French
sky hussar,Dissension,2,,French
slithering shade,Dissension,1,,French
stoic ephemera,Dissension,1,,French
transguild courier,Dissension,1,,French
Just need a python program to do this and I've seen this is the only python project that uses the cardmarket api.
I need people who have large stocks to test the new much faster pymkm.
Please get in touch here if you are interested. Checkout the async
branch and try it out!
Hey,
after some time using your amazing tool, I have a feature suggestion that would really help imo:
Generally, most calculated prices are close enough to what I would manually set. However that is not the case for cards in really bad condition. It would be awesome to be able to set discounts based on condition in the config.json, e.g. 10% lower price for GD, 20% for LP and so on.
Just a suggestion, thank you again for your work!
hi, i have this problem, when I go to click on one of the options
Action number: 4
Traceback (most recent call last):
File "C:\Users\Samuele\Desktop\Samuele\pymkm-master\newpymkm\main.py", line 19, in
main()
File "C:\Users\Samuele\Desktop\Samuele\pymkm-master\newpymkm\main.py", line 15, in main
app.start()
File "C:\Users\Samuele\Desktop\Samuele\pymkm-master\newpymkm\pymkm_app.py", line 97, in start
menu.show()
File "C:\Users\Samuele\Desktop\Samuele\pymkm-master\newpymkm\micro_menu.py", line 38, in show
func(**kwargs)
File "C:\Users\Samuele\Desktop\Samuele\pymkm-master\newpymkm\pymkmapi.py", line 25, in wrapper
return_value = func(*arg, **kwargs)
File "C:\Users\Samuele\Desktop\Samuele\pymkm-master\newpymkm\pymkm_app.py", line 202, in find_deals_from_user
self.report("find deals from user")
File "C:\Users\Samuele\Desktop\Samuele\pymkm-master\newpymkm\pymkm_app.py", line 48, in report
if ALLOW_REPORTING and not self.config['dev_mode']:
KeyError: 'dev_mode'
how i can resolve this error?
Hi,
thanks for the tool.
I getting this error:
pymkm.pymkmapi - ERROR - <Response [403]> for https://api.cardmarket.com/ws/v2.0/output.json/account
Could you please help?
Hello
First of all, thank you. I learned alot of your code :-).
I have a problem, that i sadly can not resolve by myself and i hope for a input from a kind soul.
pymkm tool gives me always a KeyError: 'isFoil'. I tried different Index (1.1; 1.41; 1.42) and always get the KeyError on Win10 and Win7. I also tried the "Hack" in the code, but it didnt help.
In the Attachments is my Python Shell.
I did not try everything in the tool, but everything else seems to work wonderfull.
When updating stock prices, app crash with error message :
File "C:\Users\Calie\Documents\pymkm\pymkm_app.py", line 618, in get_article_with_updated_price
article['isFoil'],
KeyError: 'isFoil'
Yugioh Cards don't have 'isFoil' attribute :
{'idArticle': 530741424, 'idProduct': 369122, 'language': {'idLanguage': 2, 'languageName': 'French'}, 'price': 1, 'count': 1, 'product': {'idGame': 3, 'enName': 'Dark Magician', 'locName': 'Magicien Sombre', 'image': '/srv/home/www/img/items/5/SS01/369122.jpg', 'expansion': 'Speed Duel Starter Decks: Destiny Masters', 'nr': 'A01', 'expIcon': '3', 'rarity': 'Common'}, 'isSigned': False}
Greeting @andli ,
First of all, very nice tool, for quite some time I want to start something similar.
However, I always imagine something with web-bases UI client, using Django maybe.
Are you interested in start something similar that can work as top layer connected to cardmarket API where a user can better managing his store?
Best regards,
André Cardoso
Scenario:
Unfortunately, import from csv don't work even after last fix.
Most failures are due to mismatching set names or multiple versions of cards.
Error happen with list.csv in the repo :(
Option 6 6: Wantslists cleanup suggestions
crashes
Avoid a crash
(3.6.9/envs/pymkm) ➜ pymkm git:(master) ✗ python pymkm.py
╭─── PyMKM 2.0.4 ────────────────────────────────────────╮
│ 1: Update stock prices │
│ 2: Update price for a product │
│ 3: List competition for a product │
│ 4: Find deals from a user │
│ 5: Show top 20 expensive items in stock │
│ 6: Wantslists cleanup suggestions │
│ 7: Show account info │
│ 8: Clear entire stock (WARNING) │
│ 9: Import stock from list.csv │
│ 10: Track price data to prices.csv │
│ 0: Exit │
├────────────────────────────────────────────────────────┤
│ API calls used today: 1073/5000 │
╰────────────────────────────────────────────────────────╯
Action number: 6
This will show items in your wantslists you have already received.
Gettings wantslists from Cardmarket...
Wantslists cached (21 items).
Wantslists_Lists cached (21 items).
Gettings received orders from Cardmarket...
Matching received purchases with wantslists...
N/A% (0 of 179) | | Elapsed Time: 0:00:00 ETA: --:--:--Traceback (most recent call last):
File "pymkm.py", line 51, in <module>
main()
File "pymkm.py", line 46, in main
app.start(args)
File "/Users/guillaume/dev/pymkm/pymkm/pymkm_app.py", line 184, in start
break_signal = menu.show()
File "/Users/guillaume/.pyenv/versions/3.6.9/envs/pymkm/lib/python3.6/site-packages/micromenu.py", line 48, in show
func(**kwargs)
File "/Users/guillaume/dev/pymkm/pymkm/pymkm_app.py", line 787, in clean_purchased_from_wantslists
"wantlist_name": wantslists[key],
IndexError: list index out of range
pymkm/pymkm_app.py:785
needs a better wantlist lookup
When I try to use your script I cannot insert any stock.
I looked at the reponse and cardmarket returns, for example:
r.content
b'{"inserted":[{"success":false,"tried":{"idProduct":"2767","idLanguage":"1","count":"1","comments":"a","price":"0.13","condition":"nm","isFoil":"false","amount":"1"},"error":"An error has ocurred, the card has NOT been listed."}]}'
So it says success is dalse, and the error is just "An error has ocurred, the card has NOT been listed".
Does the code work on your side?
Hi! As I've been listing more and more cards, I recently exceeded 5000 different products so I'm running out of API-requests. Is there a way I can update only part of the stock with option 1? Like the first 4000 products one day and the rest on the next day?
This may not be relevant for most users so if I can add those limits to my local code that would help a lot already. Thanks for your great work once again!
Sorry Andreas but im a noob :) I hope you can help me. I installed python i tried to run the pip install command but its not working.
Do i need to put your pymkm-master files inside the python instal path? IDK sorry for this and thanks in advance :)
As you asked me to open a seperate issue, here it is :)
Sometimes not all price updates shown in the best/worst diffs list are actually applied. Not sure how to reproduce this. I just updated 3000 products and printed the 30 best diffs. Out of those, 6 prices were not updated to the printed new value.
I'm pretty sure this happened in the old version too.
seems to happen only when a lot of prices have to get updated, maybe an issue with the chunking to 100 at a time?
Hello,
I get this error while executing action numeber 4:
Action number: 4
Traceback (most recent call last):
File "main.py", line 539, in
main()
File "main.py", line 73, in main
show_top_expensive_articles_in_stock(20, api=api)
File "/home/redhat/pymkm/pymkm.py", line 29, in call
return_value = self.function(*arg, **kwargs)
File "main.py", line 438, in show_top_expensive_articles_in_stock
[article['product']['enName'], article['product']['expansion'], u'\u2713' if article['isFoil'] else '', article['language']['languageName'] if article['language'] != 1 else '', article['price']])
KeyError: 'expansion'
Running python3 on:
Linux belatrix 4.9.0-9-amd64 #1 SMP Debian 4.9.168-1+deb9u2 (2019-05-13) x86_64 GNU/Linux
The language of imported cards are changed to "French".
Steps to reproduce the behavior:
Card,Set Name,Quantity,Foil,Language
Heliod's Pilgrim,Theros Beyond Death,1,,English
Dreadful Apathy,Theros Beyond Death,1,,English
Indomitable Will,Theros Beyond Death,1,,English
Triumphant Surge,Theros Beyond Death,1,,English
Pious Wayfarer,Theros Beyond Death,1,,English
Cards imported to Cardmarket should be in English Language.
Cards imported to Cardmarket are in French Language
Ubuntu 18.04 // Python 3.8.7
PyMkm 2.3.0
Tried to import the following list.csv (Master branch):
Card,Set Name,Quantity,Foil,Language
Tormented Soul,Magic 2012,1,,German
Steps to reproduce the behavior:
Card is listed as usual
Nothing happened
Ubuntu 20.04
Hi,
Might be user error but I follow the example in your readme for hydroid I get the following error:
Action number: 3
Search card name:
hydroid
Foil? [y/n]:
n
Traceback (most recent call last):
File "main.py", line 19, in
main()
File "main.py", line 15, in main
app.start()
File "D:\Temp\PYMKM2\pymkm_app.py", line 65, in start
search_string, is_foil, api=self.api)
File "D:\Temp\PYMKM2\pymkmapi.py", line 25, in wrapper
return_value = func(*arg, **kwargs)
File "D:\Temp\PYMKM2\pymkm_app.py", line 191, in list_competition_for_product
product = products[0]
IndexError: list index out of range
(base) D:\Temp\PYMKM2>
(base) D:\Temp\PYMKM2>
Using Python 3.7.1 anaconda environment
I've managed to get the get_product working but not this piece.
Apologies if user error.
Hi,
Today I got this error while trying to search for some deals:
Searching top X expensive cards for deals, choose X (1-539):
300
25% (76 of 300) |######################################### | Elapsed Time: 0:00:25 ETA: 0:01:17Traceback (most recent call last):
File "main.py", line 19, in <module>
main()
File "main.py", line 15, in main
app.start()
File "/Users/ruben/Downloads/pymkm/pymkm_app.py", line 97, in start
menu.show()
File "/Users/ruben/Downloads/pymkm/micro_menu.py", line 38, in show
func(**kwargs)
File "/Users/ruben/Downloads/pymkm/pymkmapi.py", line 25, in wrapper
return_value = func(*arg, **kwargs)
File "/Users/ruben/Downloads/pymkm/pymkm_app.py", line 232, in find_deals_from_user
expansion = p['product']['expansion']['enName']
KeyError: 'expansion'
Thanks for the great tool!
When the stock contains this card: https://www.cardmarket.com/de/Magic/Products/Singles/2006-Player-Cards/Carlos-Romao
the whole script crashes and no prices get updated
Steps to reproduce the behavior:
If the special char cannot be used for the stock update, a graceful handling without crashing the whole update would be great
crash, no prices updated but articles are written to partial_update anyway
Ubuntu 20.04
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.