diff --git a/README.md b/README.md
index 26fcc17..4a06a4f 100644
--- a/README.md
+++ b/README.md
@@ -42,19 +42,21 @@ Now you have two options: the **script with a User Interface** *(like a true sof
> python3 cw-wizard.py -h
```
```text
-usage: CW Wizard [-h] [-v] -w wantlist_URLS [wantlist_URLS ...] [-m MAX_SELLERS] [-c]
+usage: CW Wizard [-h] [-v] -u WANTLIST_URLS [WANTLIST_URLS ...] [-m MAX_SELLERS] [-w] [-c]
CW Wizard, Find the best bundles for the cards in your wantlist(s).
optional arguments:
-h, --help show this help message and exit
-v, --version show program's version number and exit
- -w wantlist_URLS [wantlist_URLS ...], --wantlist-urls wantlist_URLS [wantlist_URLS ...]
+ -u WANTLIST_URLS [WANTLIST_URLS ...], --wantlist-urls WANTLIST_URLS [WANTLIST_URLS ...]
wantlist url(s) (if you pass multiples whislists, separate them with spaces)
-m MAX_SELLERS, --max-sellers MAX_SELLERS
maximum number of sellers to display on the result page
- -c, --continue-on-error
+ -w, --continue-on-warning
if specified the script will continue on non fatal errors
+ -c, --articles-comment
+ if specified the sellers comments will be added to the result page
```
As you can see, you can call the script with one or more wantlist urls, and there is optional arguments available ([info on script arguments](https://github.com/BenSouchet/cw-wizard/blob/main/README.md#script-arguments)).
@@ -79,9 +81,20 @@ With the command line version of the script you can use the following arguments:
|:-------------:|:-----------:|:--------:|
| `-v` *OR* `--version` | Display the version number of the script in your terminal | No |
| `-h` *OR* `--help` | Display the help in your terminal | No |
-| `-w` *OR* `--wantlist_urls` | One or more Cardmarket wantlists (wantlists) urls.
If you add multiple urls simply put a space between then (not a comma). | **Yes** |
-| `-m` *OR* `--max_sellers` | The maximum number of sellers to display on the result page.
Default value `20`. `0` means display all. | No |
-| `-c` *OR* `--continue_on_error` | Whatever to stop on non fatal requests errors.
Default value `False`. | No |
+| `-u` *OR* `--wantlist-urls` | One or more Cardmarket wantlists (wantlists) urls.
If you add multiple urls simply put a space between then (not a comma). | **Yes** |
+| `-m` *OR* `--max-sellers` | The maximum number of sellers to display on the result page.
Default value `20`. `0` means display all. | No |
+| `-w` *OR* `--continue-on-warning` | If specified the script won't stop on non fatal requests errors. | No |
+| `-c` *OR* `--articles-comment` |If specified the script will retrieve and add sellers comments to the result page. | No |
+
+## Version
+Current version is `1.0.0`, you can download this latest release on the Releases category (on the sidebar), from [this page](https://github.com/BenSouchet/cw-wizard/releases) or `git clone` the `main` branch of the repository.
+
+### Latest Version Changelog
+- Handle more than the 50 first articles for the card pages (see function [`load_more_articles()`]()).
+- Skip article and sellers that doesn't ship to your address.
+- Extract and display sellers comments for articles (if script argument `-c` is specified).
+- Add number or sales of the current seller when you display the cards list.
+- Minors code simplification.
## Sorting Relevant Sellers
Currently the most relevant sellers are the ones with the most cards you are looking for in your wantlists.
diff --git a/assets/css/style.css b/assets/css/style.css
index 8010f9d..51dd526 100644
--- a/assets/css/style.css
+++ b/assets/css/style.css
@@ -197,13 +197,18 @@ a.seller-name:focus {
}
#popup-header {
display: grid;
- grid-template-columns: 1fr auto;
+ grid-template-columns: auto 1fr auto;
place-items: start;
+ gap: .8rem;
+ padding-top: .2rem;
+}
+#popup-header .close-popup {
+ line-height: 1em;
}
.card-item {
width: 100%;
display: grid;
- grid-template-columns: 34px 24px 1fr 66px 1px;/* Last column for the scrollbar */
+ grid-template-columns: 34px 24px auto 1fr 66px 1px;/* Last column for the scrollbar */
place-items: center start;
gap: 0.8rem;
padding: 2px 8px;
@@ -311,6 +316,14 @@ a.seller-name:focus {
.card-item span:last-of-type {
justify-self: end;
}
+.card-item .card-comment {
+ font-size: 0.9em;
+ color: #a58155;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ width: 100%;
+}
#list-header {
margin-top: .8rem;
font-weight: 500;
@@ -318,13 +331,18 @@ a.seller-name:focus {
}
#popup-seller-name {
font-size: 1.4rem;
+ line-height: 1.3em;
+ align-self: end;
+}
+#popup-seller-sales-number {
+ align-self: end;
}
#cards-list {
display: grid;
grid-auto-flow: row;
overflow-y: scroll;
color: #d3a164;
- height: calc(100vh - 116px);/* Yes, this an hardcoded value. Bad. Bad. Bad...*/
+ max-height: calc(100vh - 116px);/* Yes, this an hardcoded value. Bad. Bad. Bad...*/
}
#outside-popup {
position: fixed;
diff --git a/assets/js/main.js b/assets/js/main.js
index c817e93..23e25c8 100644
--- a/assets/js/main.js
+++ b/assets/js/main.js
@@ -21,6 +21,11 @@ function showCardsList(seller_id) {
seller_link_popup_tag.href = seller_link_tag.href
seller_link_popup_tag.innerText = seller_link_tag.innerText;
+ var seller_sales_number_tag = document.getElementById("seller-"+seller_id+"-sales-number");
+ var seller_sales_popup_tag = document.getElementById("popup-seller-sales-number");
+ if (!seller_sales_popup_tag) { return false; }
+ seller_sales_popup_tag.innerText = '('+ seller_sales_number_tag.innerText + ' Sales)';
+
// Step 4: Block overflow body
var body = document.querySelector("body");
body.style.overflow = "hidden";
@@ -38,4 +43,6 @@ function closePopup() {
// Step 2: Block overflow body
var body = document.querySelector("body");
body.style.overflow = "auto";
-}
\ No newline at end of file
+
+ return false;
+}
diff --git a/assets/template.html b/assets/template.html
index 06a3739..70b0d88 100644
--- a/assets/template.html
+++ b/assets/template.html
@@ -16,7 +16,7 @@
Easily find the sellers with the most cards you are looking for!
-
wantlist(s) you give to the Wizard:
+
Wantlist(s) you give to the Wizard:
@@ -30,12 +30,12 @@ Most Relevant Sellers ():
diff --git a/core.py b/core.py
index d4d66db..f004ded 100644
--- a/core.py
+++ b/core.py
@@ -1,7 +1,7 @@
-import os
import re
import sys
import json
+import base64
import logging
import requests
@@ -11,7 +11,7 @@
SCRIPT_NAME = 'CW Wizard'
-VERSION = 0.2
+VERSION = '1.0.0'
EXIT_ERROR_MSG = 'The Wizard encountered issue(s) please check previous logs.\n'
EXIT_SUCCESS_MSG = 'The Wizard has finish is work, have a great day!\n'
@@ -21,6 +21,7 @@
CURR_GAME = 'Magic'
CARDMARKET_BASE_URL = 'https://www.cardmarket.com'
+CARDMARKET_BASE_URL_REGEX = r'^https:\/\/www\.cardmarket\.com'
# This value can be overwriten via script arguments or via GUI
MAXIMUM_SELLERS = 20
@@ -33,6 +34,9 @@
CARD_CONDITIONS = { 'Mint': 1, 'Near Mint': 2, 'Excellent': 3,
'Good': 4, 'Light Played': 5, 'Played': 6, 'Poor': 7, }
+CARD_CONDITIONS_SHORTNAMES = { 'Mint': 'MT', 'Near Mint': 'NM', 'Excellent': 'EX',
+ 'Good': 'GD', 'Light Played': 'LP', 'Played': 'PL', 'Poor': 'PO', }
+
# These request errors description are from https://api.cardmarket.com/ws/documentation/API_2.0:Response_Codes
REQUEST_ERRORS = { 307: ['Temporary Redirect', 'Particular requests can deliver thousands of entities (e.g. a large stock or requesting articles for a specified product, and many more). Generally all these request allow you to paginate the results - either returning a 206 or 204 HTTP status code. Nevertheless, all these requests can also be done without specifying a pagination. As general values for force-paginated requests please use maxResults=100 in order to avoid being 307\'d again. The first result is indexed with 0: start=0.'],
400: ['Bad Request', 'Whenever something goes wrong with your request, e.g. your POST data and/or structure is wrong, or you want to access an article in your stock by providing an invalid ArticleID, a 400 Bad Request HTTP status is returned, describing the error within the content.'],
@@ -61,23 +65,29 @@ def addError(self, message):
self.status = 'error'
self.messages.append({ 'type': 'error', 'content': message, 'logged': False })
- def addDetailedRequestError(self, task, response):
+ def addDetailedRequestError(self, task, response, as_warning=False):
status_code = response.status_code
- self.addError('Unable to {}. Request status code "{}":'.format(task, str(status_code)))
+ message = 'Unable to {}. Request status code "{}":'.format(task, str(status_code))
# Check if we have more info on the request error
status_code_info = REQUEST_ERRORS.get(status_code)
+ detailed_message = 'Unknown status code!'
if status_code_info:
# Log the additional info
- self.addError('{} -- {}'.format(status_code_info[0], status_code_info[1]))
+ detailed_message = '{} -- {}'.format(status_code_info[0], status_code_info[1])
+
+ if as_warning:
+ self.addWarning(message)
+ self.addWarning(detailed_message)
else:
- self.addError('Unknown status code!')
+ self.addError(message)
+ self.addError(detailed_message)
def append(self, result):
if result.status == 'error':
- self.result = 'error'
+ self.status = 'error'
if result.status == 'warning' and self.status == 'valid':
- self.result = 'warning'
+ self.status = 'warning'
self.messages = [*self.messages, *result.messages]
def addResult(self, element):
@@ -226,7 +236,7 @@ def cardmarket_log_out(session, silently=False):
return funct_result
-def retrieve_wantlist(session, wantlist_url):
+def retrieve_wantlist(session, wantlist_url, continue_on_warning=False):
funct_result = FunctResult()
LOG.debug(' |____ The Wizard is retrieving the wantlist ("{}")...'.format(wantlist_url))
@@ -237,7 +247,7 @@ def retrieve_wantlist(session, wantlist_url):
response_get_wantlist = session.get(wantlist_url)
if response_get_wantlist.status_code != 200:
# Issue with the request
- funct_result.addDetailedRequestError('access to the wantlist ("{}")'.format(wantlist_url), response_get_wantlist)
+ funct_result.addDetailedRequestError('access to the wantlist ("{}")'.format(wantlist_url), response_get_wantlist, continue_on_warning)
return funct_result
# Step 2: Convert response to BeautifulSoup object
@@ -287,7 +297,75 @@ def retrieve_wantlist(session, wantlist_url):
funct_result.addResult(wantlist)
return funct_result
-def populate_sellers_dict(session, sellers, wantlist, continue_on_error=False):
+def _get_load_more_args(card, product_id):
+ args_dict = { 'page': '0' }
+ filter_settings = {}
+ filter_settings['idLanguage'] = {str(CARD_LANGUAGES[language]): CARD_LANGUAGES[language] for language in card['languages']}
+ for attribute in ['isReverse', 'isSigned', 'isFirstEd', 'isAltered']:
+ if card[attribute] != 'Any':
+ filter_settings[attribute] = card[attribute]
+ condition = [shortname for shortname in CARD_CONDITIONS_SHORTNAMES.values()]
+ if card['minCondition'] != 'Poor':
+ condition = condition[:condition.index(CARD_CONDITIONS_SHORTNAMES[card['minCondition']]) + 1]
+ filter_settings['condition'] = condition
+ args_dict['filterSettings'] = json.dumps(filter_settings, separators=('\\,', ':'))
+ args_dict['idProduct'] = product_id
+
+ return args_dict
+
+def _get_load_more_product_id(load_more_btn):
+ onclick_str = load_more_btn['onclick']
+ return re.search(r'\'idProduct\'\:\'(?P\d+)\'', onclick_str).group('product_id')
+
+def _get_load_more_request_token(load_more_btn):
+ onclick_str = load_more_btn['onclick']
+ return re.match(r'jcp\(\'(?P[A-Z0-9%]+)\'', onclick_str).group('token')
+
+def load_more_articles(session, funct_result, soup, card, articles_table):
+ # Step 1: Check if there isn't a load more articles button, in this case we stop
+ load_more_btn = soup.find(id='loadMoreButton')
+ if not load_more_btn:
+ return None
+
+ # Step 2: Initialize variables
+ active = True
+ card_curr_game = re.match(CARDMARKET_BASE_URL_REGEX + r'\/\w{2}\/(\w+)', card['url']).group(1)
+ product_id = _get_load_more_product_id(load_more_btn)
+ load_more_args = _get_load_more_args(card, product_id)
+ request_token = _get_load_more_request_token(load_more_btn)
+
+ # Step 3: Retrieve more article until card['maxPrice'] is reached or there is no more article to load
+ while active:
+ # Step 3.A: Get the price of the last card currently displayed
+ last_article = articles_table.contents[-1]
+ last_article_price_str = last_article.find('div', class_='price-container').find('span', class_='text-right').contents[0]
+ last_article_price = Decimal(last_article_price_str.split(' ')[0].replace('.','').replace(',','.'))
+
+ # Step 3.B: Check if we need to load more articles, if yes send a new request to get more articles.
+ if last_article_price <= card['maxPrice']:
+ # Step 3.B.I: Initialize a payload and do a POST request
+ args_base64 = base64.b64encode(bytes(json.dumps(load_more_args, separators=(',', ':')), 'utf-8'))
+ payload = {'args': request_token + args_base64.decode("utf-8")}
+ response_post_load_article = session.post('{}/{}/{}/AjaxAction'.format(CARDMARKET_BASE_URL, CURR_LANG, card_curr_game), data=payload)
+ if response_post_load_article.status_code != 200:
+ # Issue with the request
+ funct_result.addWarning('Failed to load more articles for card page ("{}")'.format(card['title']))
+ # We cannot retrieve more articles, so break the loop
+ break
+
+ # Step 3.B.II: Handle the request result containing the new articles and the new page_index value
+ more_article_soup = BeautifulSoup(response_post_load_article.text, 'html.parser')
+ load_more_args['page'] = int(more_article_soup.find('newpage').contents[0])
+
+ articles_rows_html_str = base64.b64decode(more_article_soup.find('rows').contents[0]).decode("utf-8")
+ articles_table.append(BeautifulSoup(articles_rows_html_str, 'html.parser'))
+ if load_more_args['page'] < 0:
+ # There is no more article available, stop the process
+ active = False
+ else:
+ active = False
+
+def populate_sellers_dict(session, sellers, wantlist, articles_comment=False, continue_on_warning=False):
funct_result = FunctResult()
wantlist_url = wantlist.pop(0)
@@ -313,55 +391,79 @@ def populate_sellers_dict(session, sellers, wantlist, continue_on_error=False):
response_get_card_articles = session.get(card['url'], params=params)
if response_get_card_articles.status_code != 200:
# Issue with the request
- funct_result.addDetailedRequestError('access the card page ("{}")'.format(card['title']), response_get_card_articles)
- if continue_on_error:
+ funct_result.addDetailedRequestError('access the card page ("{}")'.format(card['title']), response_get_card_articles, continue_on_warning)
+ if continue_on_warning:
continue
return funct_result
card_full_url = response_get_card_articles.url
- # Step 3: Retrieve the articles table (BeautifulSoup object)
+ # Step 3.A: Retrieve the articles table (BeautifulSoup object)
soup = BeautifulSoup(response_get_card_articles.text, 'html.parser')
articles_table = soup.find('div', class_='table-body')
+ # Step 3.B: Load more articles if necessary
+ if isinstance(card['maxPrice'], Decimal):
+ load_more_articles(session, funct_result, soup, card, articles_table)
+
# Step 4: Iterate over articles
- for article in articles_table.children:
- # Check if this is a proper article
- if 'article-row' not in article.attrs['class']:
+ for article_row in articles_table.children:
+ # Step 4.A: Check if this is a proper article
+ if 'article-row' not in article_row.attrs['class']:
funct_result.addWarning('No offers found for card ("{}") with parameters: {} {}.'.format(card['title'], params, card['maxPrice']))
break
- seller_name_tag = article.find('span', class_='seller-name').find('a')
+ # Step 4.B: Check if the user can purchase the item, ship to is address available from the seller.
+ action_container = article_row.find('div', class_='actions-container')
+ if not action_container.find('div', class_='input-group'):
+ # Cannot purchase, skip this article_row
+ continue
+
+ # Step 4.C: Retrieve Seller info
+ seller_name_tag = article_row.find('span', class_='seller-name').find('a')
seller_name = seller_name_tag.contents[0]
- # Step 4.A: Skip if we already added an article (of this card) for this seller
+ seller_sales_info_wrapper = article_row.find('span', class_='seller-extended').contents[1]
+ seller_sales_number = re.match(r'^\d+', seller_sales_info_wrapper['title']).group(0)
+
+ # Step 4.D Skip if we already added an article (of this card) for this seller
if seller_name in card_sellers_names:
- # Skip this article
+ # Skip this article_row
continue
seller_profile_url = CARDMARKET_BASE_URL + seller_name_tag['href']
- price_str = article.find('div', class_='price-container').find('span', class_='text-right').contents[0]
+ price_str = article_row.find('div', class_='price-container').find('span', class_='text-right').contents[0]
price = Decimal(price_str.split(' ')[0].replace('.','').replace(',','.'))
- # Step 4.B: Check if price isn't above maxPrice
+ # Step 4.E: Check if price isn't above maxPrice
if isinstance(card['maxPrice'], Decimal) and price > card['maxPrice']:
# The current article price is superior than the max price
# we stop iterate over article (article are listed according to price)
break
- # Step 4.C: Create the new article
- article_attributes = article.find('div', class_='product-attributes')
+ # Step 4.F: Create the new article
+ article_attributes = article_row.find('div', class_='product-attributes')
article_condition = article_attributes.a.span.contents[0]
article_language = article_attributes.find('span', class_='icon')['data-original-title']
- article = { 'name': card['title'], 'url': card_full_url, 'language': article_language, 'condition': article_condition, 'price': price }
- # Step 4.D: Add this article on the seller key in the dict
+ article_dict = { 'name': card['title'], 'url': card_full_url, 'language': article_language, 'condition': article_condition, 'price': price }
+
+ # Step 4.G: Handle seller comment for the article
+ if articles_comment:
+ article_comment = ""
+ article_comment_wrapper = article_row.find('div', class_='product-comments')
+ if article_comment_wrapper:
+ article_comment = article_comment_wrapper.find('span', class_='text-truncate').contents[0]
+
+ article_dict['comment'] = article_comment
+
+ # Step 4.H: Add this article on the seller key in the dict
if seller_name in sellers:
- sellers[seller_name]['cards'].append(article)
+ sellers[seller_name]['cards'].append(article_dict)
else:
- sellers[seller_name] = {'url': seller_profile_url, 'cards': [ article ] }
+ sellers[seller_name] = {'url': seller_profile_url, 'sales': seller_sales_number, 'cards': [ article_dict ] }
- # Step 4.E: Add seller name in the corresponding list
+ # Step 4.I: Add seller name in the corresponding list
card_sellers_names.append(seller_name)
return funct_result
@@ -443,11 +545,15 @@ def build_result_page(wantlists_info, max_sellers, sellers, relevant_sellers):
seller_index = 0
for relevant_seller in relevant_sellers:
index_5_digits_str = '{:05}'.format(seller_index)
- sellers_html_str += ''.format(sellers[relevant_seller[0]]['url'], index_5_digits_str, relevant_seller[0], str(relevant_seller[1]), str(relevant_seller[2]), index_5_digits_str)
+ sellers_html_str += ''.format(sellers[relevant_seller[0]]['url'], index_5_digits_str, relevant_seller[0], index_5_digits_str, sellers[relevant_seller[0]]['sales'], str(relevant_seller[1]), str(relevant_seller[2]), index_5_digits_str)
# Concatenate cards list
sellers_cards_lists_html_str += ''.format(index_5_digits_str)
+
for card in sellers[relevant_seller[0]]['cards']:
- sellers_cards_lists_html_str += '
'.format(card['condition'], card['condition'], card['language'], card['url'], card['name'], card['price'])
+ article_comment = ""
+ if 'comment' in card:
+ article_comment = card['comment']
+ sellers_cards_lists_html_str += '
'.format(card['condition'], card['condition'], card['language'], card['url'], card['name'], article_comment, article_comment, card['price'])
sellers_cards_lists_html_str += '
'
seller_index += 1
@@ -490,7 +596,7 @@ def build_result_page(wantlists_info, max_sellers, sellers, relevant_sellers):
return funct_result
-def cardmarket_wantlist_wizard(credentials, wantlist_urls, continue_on_error, max_sellers):
+def cardmarket_wantlist_wizard(credentials, wantlist_urls, continue_on_warning, max_sellers, articles_comment):
funct_result = FunctResult()
LOG.debug('------- Calling the Wizard...\r\n')
@@ -512,17 +618,14 @@ def cardmarket_wantlist_wizard(credentials, wantlist_urls, continue_on_error, ma
LOG.debug('------- Handling the wantlist(s)')
for wantlist_url in wantlist_urls:
# Step 2: Retrieve wantlist in JSON
- retrieve_result = retrieve_wantlist(session, wantlist_url)
+ retrieve_result = retrieve_wantlist(session, wantlist_url, continue_on_warning)
retrieve_result.logMessages()
+ funct_result.append(retrieve_result)
if retrieve_result.isWarning():
- # Empty wantlist
+ # Empty wantlist, or unable to retrieve wantlist but continue_on_warning is True
continue
elif not retrieve_result.isValid():
- if continue_on_error:
- # Skip to next wantlist
- continue
# Only break, not return so we can still log out of Cardmarket
- funct_result.append(retrieve_result)
break
wantlist = retrieve_result.getResult()
@@ -531,19 +634,20 @@ def cardmarket_wantlist_wizard(credentials, wantlist_urls, continue_on_error, ma
wantlists_info.append((wantlist_url, wantlist.pop(0)))
# Step 3: Populate the sellers dictionary
- populate_result = populate_sellers_dict(session, sellers, wantlist, continue_on_error)
+ populate_result = populate_sellers_dict(session, sellers, wantlist, continue_on_warning=continue_on_warning, articles_comment=articles_comment)
populate_result.logMessages()
funct_result.append(populate_result)
# Step 4: Display most relevant sellers
- if funct_result.isValid() or continue_on_error:
+ if funct_result.isValid() or (funct_result.isWarning() and continue_on_warning):
relevant_sellers = determine_relevant_sellers(sellers, max_sellers)
- build_result = build_result_page(wantlists_info, max_sellers, sellers, relevant_sellers)
- build_result.logMessages()
+ if relevant_sellers:
+ build_result = build_result_page(wantlists_info, max_sellers, sellers, relevant_sellers)
+ build_result.logMessages()
- funct_result.append(populate_result)
+ funct_result.append(populate_result)
# Step 5: Logout from Cardmarket, simply a safety mesure.
logout_result = cardmarket_log_out(session)
@@ -611,7 +715,7 @@ def check_wantlists_and_max_sellers(wantlist_urls, max_sellers, silently=False):
if not isinstance(wantlist_url, str):
funct_result.addError('wantlist url need to be of type string.')
continue
- matched = re.match(r'^https:\/\/www\.cardmarket\.com\/(\w{2})\/(\w+)\/Wants\/\d+$', wantlist_url)
+ matched = re.match(CARDMARKET_BASE_URL_REGEX + r'\/(\w{2})\/(\w+)\/Wants\/\d+$', wantlist_url)
if not matched:
funct_result.addError('Invalid wantlist url ("{}"), valid pattern is:'.format(wantlist_url))
funct_result.addError(CARDMARKET_BASE_URL + '///Wants/')
diff --git a/cw-wizard-gui.py b/cw-wizard-gui.py
index 8a46319..46a0232 100644
--- a/cw-wizard-gui.py
+++ b/cw-wizard-gui.py
@@ -134,7 +134,7 @@ def close_window(window):
def wizard_wrapper(credentials, wantlist_urls, max_sellers):
# Step 1: Call the Wizard
- result = cardmarket_wantlist_wizard(credentials, wantlist_urls, continue_on_error=True, max_sellers=max_sellers)
+ result = cardmarket_wantlist_wizard(credentials, wantlist_urls, continue_on_warning=True, max_sellers=max_sellers)
result.logMessages()
# Step 2: Push result into the thread queue
diff --git a/cw-wizard.py b/cw-wizard.py
index 61e2598..43af42a 100644
--- a/cw-wizard.py
+++ b/cw-wizard.py
@@ -43,7 +43,7 @@ def get_credentials_user_inputs():
return funct_result
-def main(wantlist_urls, continue_on_error, max_sellers):
+def main(wantlist_urls, continue_on_warning, max_sellers, articles_comment):
"""Entry point of the CW Wizard script"""
# Step 1: Check input parameters before calling the Wizard
@@ -80,7 +80,7 @@ def main(wantlist_urls, continue_on_error, max_sellers):
return LOG.error(EXIT_ERROR_MSG)
# Step 3: Call the Wizard
- result = cardmarket_wantlist_wizard(credentials, wantlist_urls, continue_on_error=continue_on_error, max_sellers=max_sellers)
+ result = cardmarket_wantlist_wizard(credentials, wantlist_urls, continue_on_warning=continue_on_warning, max_sellers=max_sellers, articles_comment=articles_comment)
result.logMessages()
if not result.isValid():
@@ -91,12 +91,13 @@ def main(wantlist_urls, continue_on_error, max_sellers):
if __name__ == '__main__':
import argparse
- parser = argparse.ArgumentParser(prog=SCRIPT_NAME, description='CW Wizard, Find the best bundles for the cards in your wantlist(s).')
- parser.add_argument('-v', '--version', action='version', version='%(prog)s '+str(VERSION))
- parser.add_argument('-w', '--wantlist-urls', nargs='+', required=True, type=str, action='extend', help='wantlist url(s) (if you pass multiples whislists, separate them with spaces)')
+ parser = argparse.ArgumentParser(prog=SCRIPT_NAME, description='{} v{}, Find the best bundles for the cards in your wantlist(s).'.format(SCRIPT_NAME, VERSION))
+ parser.add_argument('-v', '--version', action='version', version='%(prog)s '+ VERSION)
+ parser.add_argument('-u', '--wantlist-urls', nargs='+', required=True, type=str, action='extend', help='wantlist url(s) (if you pass multiples whislists, separate them with spaces)')
parser.add_argument('-m', '--max-sellers', type=int, default=MAXIMUM_SELLERS, help='maximum number of sellers to display on the result page')
- parser.add_argument('-c', '--continue-on-error', action='store_true', help='if specified the script will continue on non fatal errors')
+ parser.add_argument('-w', '--continue-on-warning', action='store_true', help='if specified the script will continue on non fatal errors')
+ parser.add_argument('-c', '--articles-comment', action='store_true', help='if specified the sellers comments will be added to the result page')
arguments = parser.parse_args()
- main(arguments.wantlist_urls, arguments.continue_on_error, arguments.max_sellers)
+ main(arguments.wantlist_urls, arguments.continue_on_warning, arguments.max_sellers, arguments.articles_comment)