Fix LIFETIME duration
This commit is contained in:
parent
ef599c4f1c
commit
bb095bbd86
@ -64,7 +64,7 @@ class Ticket:
|
|||||||
self.token = token
|
self.token = token
|
||||||
self.type = TicketType[data['type']]
|
self.type = TicketType[data['type']]
|
||||||
self.version = data['version']
|
self.version = data['version']
|
||||||
self.expire = 75616 if self.type == TicketType.LIFETIME else data['expire']
|
self.expire = data['expire']
|
||||||
|
|
||||||
|
|
||||||
def __repr__(self) -> str:
|
def __repr__(self) -> str:
|
||||||
@ -85,10 +85,12 @@ class Ticket:
|
|||||||
product details, and configuration.
|
product details, and configuration.
|
||||||
"""
|
"""
|
||||||
current = datetime.now() # Current date and time
|
current = datetime.now() # Current date and time
|
||||||
expire = current + timedelta(days=self.expire) # Expiration date
|
|
||||||
|
|
||||||
# Determine products that this ticket covers
|
# Expiration date
|
||||||
products = self.PRODUCTS if self.type in (TicketType.LIFETIME, TicketType.SUBSCRIBER) else []
|
if self.type == TicketType.LIFETIME:
|
||||||
|
expire = datetime.fromisoformat('2231-10-10T13:22:44')
|
||||||
|
else:
|
||||||
|
expire = current + timedelta(days=self.expire)
|
||||||
|
|
||||||
# Ticket configuration based on ticket type
|
# Ticket configuration based on ticket type
|
||||||
config = {
|
config = {
|
||||||
@ -116,7 +118,7 @@ class Ticket:
|
|||||||
config['ML'] = (1, 6, 2) # Adjust machine limits
|
config['ML'] = (1, 6, 2) # Adjust machine limits
|
||||||
|
|
||||||
if self.type == TicketType.SUBSCRIBER:
|
if self.type == TicketType.SUBSCRIBER:
|
||||||
config['VP'] = self.expire # Set validity period for Subscriber type
|
config['VP'] = (expire - current).days # Set validity period for Subscriber type
|
||||||
config['VPT'] = round(expire.timestamp()) # Set the expiration timestamp
|
config['VPT'] = round(expire.timestamp()) # Set the expiration timestamp
|
||||||
|
|
||||||
if self.type == TicketType.FREE:
|
if self.type == TicketType.FREE:
|
||||||
@ -128,8 +130,10 @@ class Ticket:
|
|||||||
# Construct the ticket export string with MAGIC number and product details
|
# Construct the ticket export string with MAGIC number and product details
|
||||||
items = [self.MAGIC]
|
items = [self.MAGIC]
|
||||||
|
|
||||||
# Add products with expiration timestamps
|
# Determine products that this ticket covers
|
||||||
items += [f'{p}:{round(expire.timestamp())}' for p in products]
|
if self.type in (TicketType.LIFETIME, TicketType.SUBSCRIBER):
|
||||||
|
# Add products with expiration timestamps
|
||||||
|
items += [f'{p}:{round(expire.timestamp())}' for p in self.PRODUCTS]
|
||||||
|
|
||||||
# Add configuration key-value pairs
|
# Add configuration key-value pairs
|
||||||
items += [f'{k}:{v}' for k, v in config.items()]
|
items += [f'{k}:{v}' for k, v in config.items()]
|
||||||
@ -319,7 +323,7 @@ class Ticket:
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
"""Main function to parse arguments and handle ticket creation and extraction."""
|
# Set up argument parsing
|
||||||
parser = argparse.ArgumentParser(description='DVDFab-Ticket: Manage user tickets for DVDFab software.')
|
parser = argparse.ArgumentParser(description='DVDFab-Ticket: Manage user tickets for DVDFab software.')
|
||||||
|
|
||||||
# Subparsers for account actions
|
# Subparsers for account actions
|
||||||
@ -383,6 +387,6 @@ if __name__ == '__main__':
|
|||||||
# Output the serialized ticket string
|
# Output the serialized ticket string
|
||||||
print(ticket.export())
|
print(ticket.export())
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
# Print exception message if an error occurs during ticket creation or processing
|
# Print any errors that occur during execution
|
||||||
print(f'[!] {e}')
|
print(f'[!] {e}')
|
||||||
exit(1)
|
exit(1)
|
||||||
|
Loading…
Reference in New Issue
Block a user