Fix LIFETIME duration

This commit is contained in:
hyugogirubato 2024-09-30 16:28:53 +02:00
parent ef599c4f1c
commit bb095bbd86

View File

@ -64,7 +64,7 @@ class Ticket:
self.token = token
self.type = TicketType[data['type']]
self.version = data['version']
self.expire = 75616 if self.type == TicketType.LIFETIME else data['expire']
self.expire = data['expire']
def __repr__(self) -> str:
@ -85,10 +85,12 @@ class Ticket:
product details, and configuration.
"""
current = datetime.now() # Current date and time
expire = current + timedelta(days=self.expire) # Expiration date
# Determine products that this ticket covers
products = self.PRODUCTS if self.type in (TicketType.LIFETIME, TicketType.SUBSCRIBER) else []
# Expiration date
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
config = {
@ -116,7 +118,7 @@ class Ticket:
config['ML'] = (1, 6, 2) # Adjust machine limits
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
if self.type == TicketType.FREE:
@ -128,8 +130,10 @@ class Ticket:
# Construct the ticket export string with MAGIC number and product details
items = [self.MAGIC]
# Determine products that this ticket covers
if self.type in (TicketType.LIFETIME, TicketType.SUBSCRIBER):
# Add products with expiration timestamps
items += [f'{p}:{round(expire.timestamp())}' for p in products]
items += [f'{p}:{round(expire.timestamp())}' for p in self.PRODUCTS]
# Add configuration key-value pairs
items += [f'{k}:{v}' for k, v in config.items()]
@ -319,7 +323,7 @@ class Ticket:
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.')
# Subparsers for account actions
@ -383,6 +387,6 @@ if __name__ == '__main__':
# Output the serialized ticket string
print(ticket.export())
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}')
exit(1)