Skip to content

Commit

Permalink
add a advanced user filter class for more control
Browse files Browse the repository at this point in the history
reword somethings
  • Loading branch information
datawhores committed Dec 18, 2023
1 parent 516945a commit 389bae9
Showing 1 changed file with 124 additions and 118 deletions.
242 changes: 124 additions & 118 deletions ofscraper/utils/args.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,57 +273,41 @@ def create_parser(input=None):
filters.add_argument(
"-cp",
"--current-price",
help="Filter Free or paid accounts\npaid and free means your original price, and not the renewal price",
help="Filter accounts based on either the subscription price, claimable promotions, or regular price",
default=False,
required=False,
type=str.lower,
choices=["paid", "free"],
)

filters.add_argument(
"-cpn",
"--current-price-min",
help="Filter accounts where the current regular price matches or falls above the provided value",
default=False,
required=False,
type=int,
)

filters.add_argument(
"-cpm",
"--current-price-max",
help="Filter accounts where the current price matches or falls below the provided value",
default=False,
required=False,
type=int,
)

filters.add_argument(
"-rp",
"--renewal-price",
help="Filter Free or paid accounts\npaid and free means the price at renewal including promotions",
help="Filter accounts based on either the subscription price, claimable promotions, or regular price",
default=False,
required=False,
type=str.lower,
choices=["paid", "free"],
)

filters.add_argument(
"-rpn",
"--renewal-price-min",
help="Filter accounts where the renewal regular price matches or falls above the provided value",
"-gp",
"--regular-price",
help="Filter accounts based on the regular price",
default=False,
required=False,
type=int,
type=str.lower,
choices=["paid", "free"],
)

filters.add_argument(
"-rpm",
"--renewal-price-max",
help="Filter accounts where the renewal price matches or falls below the provided value",
"-pp",
"--promo-price",
help="Filter accounts based on either the all promos included unclaimable, or regular price",
default=False,
required=False,
type=int,
type=str.lower,
choices=["paid", "free"],
)

filters.add_argument(
Expand All @@ -346,81 +330,71 @@ def create_parser(input=None):
)

filters.add_argument(
"-gp",
"--regular-price",
help="Filter Free or paid accounts\npaid and free means the price at renewal excluding promotions",
"-ls",
"--last-seen",
help="Filter accounts by whether last seen is visible",
default=False,
required=False,
type=str.lower,
choices=["paid", "free"],
choices=["yes", "no"],
)

filters.add_argument(
"-gpn",
"--regular-price-min",
help="Filter accounts where the regular price matches or falls above the provided value",
"-frt",
"--free-trail",
help="Filter accounts currently in a free trial (normally paid)",
default=False,
required=False,
type=int,
type=str.lower,
choices=["yes", "no"],
)

filters.add_argument(
"-gpm",
"--regular-price-max",
help="Filter accounts where the regular price matches or falls below the provided value",
"-rw",
"--renewal",
help="Filter by whether renewal is on or off for account",
default=False,
required=False,
type=int,
type=str.lower,
choices=["active", "disabled"],
)

filters.add_argument(
"-lsb",
"--last-seen-before",
help="Filter Accounts by last seen being before the given date",
default=False,
required=False,
type=arrow_helper,
)
filters.add_argument(
"-lsa",
"--last-seen-after",
help="Filter Accounts by last seen being before the given date",
"-mp",
"--sub-status",
help="Filter by whether or not your subscription has expired or not",
default=False,
required=False,
type=arrow_helper,
type=str.lower,
choices=["active", "expired"],
)

filters.add_argument(
"-ls",
"--last-seen",
help="Filter Accounts by whether last seen is visible",
default=False,
"-ul",
"--user-list",
help='Filter by userlist\n Note: the lists "ofscraper.main,ofscraper.expired,ofscraper.active" are reserved and should not be the name of any list you have on OF',
default=[],
required=False,
type=str.lower,
choices=["yes", "no"],
type=lambda x: x.split(","),
action="extend",
)

filters.add_argument(
"-frt",
"--free-trail",
help="Filter Accounts by whether last seen is visible",
default=False,
"-bl",
"--black-list",
help='Remove all users from selected list\n Note: the lists "ofscraper.main,ofscraper.expired,ofscraper.active" are reserved should not be the name of any list you have on OF',
default=[],
required=False,
type=str.lower,
choices=["yes", "no"],
type=lambda x: x.split(","),
action="extend",
)

filters.add_argument(
"-pp",
"--promo-price",
help="Filter Free or paid accounts\npaid and free including any promotion, even if not claimable",
default=False,
required=False,
type=str.lower,
choices=["paid", "free"],
adv_filters = parser.add_argument_group(
"advanced filters",
description="Enables advanced filtering of usernames based on user-defined parameters",
)

filters.add_argument(
adv_filters.add_argument(
"-ppn",
"--promo-price-min",
help="Filter accounts where the lowest promo price matches or falls above the provided value",
Expand All @@ -429,87 +403,119 @@ def create_parser(input=None):
type=int,
)

filters.add_argument(
adv_filters.add_argument(
"-ppm",
"--promo-price-max",
help="Filter accounts where the lowest promo price matches or falls below the provided value",
default=False,
required=False,
type=int,
)
filters.add_argument(
"-rw",
"--renewal",
help="Filter by whether renewal is on or off for account",

adv_filters.add_argument(
"-gpn",
"--regular-price-min",
help="Filter accounts where the regular price matches or falls above the provided value",
default=False,
required=False,
type=str.lower,
choices=["active", "disabled"],
type=int,
)

filters.add_argument(
adv_filters.add_argument(
"-gpm",
"--regular-price-max",
help="Filter accounts where the regular price matches or falls below the provided value",
default=False,
required=False,
type=int,
)

adv_filters.add_argument(
"-cpn",
"--current-price-min",
help="Filter accounts where the current regular price matches or falls above the provided value",
default=False,
required=False,
type=int,
)

adv_filters.add_argument(
"-cpm",
"--current-price-max",
help="Filter accounts where the current price matches or falls below the provided value",
default=False,
required=False,
type=int,
)

adv_filters.add_argument(
"-rpn",
"--renewal-price-min",
help="Filter accounts where the renewal regular price matches or falls above the provided value",
default=False,
required=False,
type=int,
)

adv_filters.add_argument(
"-rpm",
"--renewal-price-max",
help="Filter accounts where the renewal price matches or falls below the provided value",
default=False,
required=False,
type=int,
)

adv_filters.add_argument(
"-lsb",
"--last-seen-before",
help="Filter accounts by last seen being before the given date",
default=False,
required=False,
type=arrow_helper,
)
adv_filters.add_argument(
"-lsa",
"--last-seen-after",
help="Filter accounts by last seen being before the given date",
default=False,
required=False,
type=arrow_helper,
)

adv_filters.add_argument(
"-ea",
"--expired-after",
help="Filter Accounts by expiration/renewal being before the given date",
help="Filter accounts by expiration/renewal being before the given date",
default=False,
required=False,
type=arrow_helper,
)
filters.add_argument(
adv_filters.add_argument(
"-eb",
"--expired-before",
help="Filter Accounts by expiration/renewal being before the given date",
help="Filter accounts by expiration/renewal being before the given date",
default=False,
required=False,
type=arrow_helper,
)
filters.add_argument(
"-mp",
"--sub-status",
help="Filter by whether or not your subscription has expired or not",
default=False,
required=False,
type=str.lower,
choices=["active", "expired"],
)

filters.add_argument(
adv_filters.add_argument(
"-sa",
"--subscribed-after",
help="Filter Accounts by subscription date being before the given date",
help="Filter accounts by subscription date being before the given date",
default=False,
required=False,
type=arrow_helper,
)
filters.add_argument(
adv_filters.add_argument(
"-sb",
"--subscribed-before",
help="Filter Accounts by sub date being before the given date",
help="Filter accounts by sub date being before the given date",
default=False,
required=False,
type=arrow_helper,
)

filters.add_argument(
"-ul",
"--user-list",
help='Filter by userlist\n Note: the lists "ofscraper.main,ofscraper.expired,ofscraper.active" are reserved and should not be the name of any list you have on OF',
default=[],
required=False,
type=lambda x: x.split(","),
action="extend",
)

filters.add_argument(
"-bl",
"--black-list",
help='Remove all users from selected list\n Note: the lists "ofscraper.main,ofscraper.expired,ofscraper.active" are reserved should not be the name of any list you have on OF',
default=[],
required=False,
type=lambda x: x.split(","),
action="extend",
)

sort = parser.add_argument_group(
"sort",
description="Controls the order of the model selection list and the scraping order",
Expand Down

0 comments on commit 389bae9

Please sign in to comment.