|
@@ -100,18 +100,18 @@ def add_subscription(conf, database, channel="", search="", playlist=""):
|
|
|
_(" successfully added"))
|
|
|
|
|
|
|
|
|
-def list_subscriptions(conf, db):
|
|
|
+def list_subscriptions(conf, database):
|
|
|
"""
|
|
|
Prints a list of subscriptions from the database.
|
|
|
|
|
|
:param conf: configuration object
|
|
|
:type conf: lib_stov.configuration.Conf
|
|
|
- :param db: database object
|
|
|
- :type db: lib_stov.database.Db
|
|
|
+ :param database: database object
|
|
|
+ :type database: lib_stov.database.Db
|
|
|
"""
|
|
|
- subscriptions_list = db.get_subscriptions(conf)
|
|
|
+ subscriptions_list = database.get_subscriptions(conf)
|
|
|
sub_state = None
|
|
|
- if len(subscriptions_list) != 0:
|
|
|
+ if subscriptions_list:
|
|
|
LOGGER.info(_("ID Title"))
|
|
|
for sub in subscriptions_list:
|
|
|
if not sub.disabled:
|
|
@@ -122,3 +122,24 @@ def list_subscriptions(conf, db):
|
|
|
" (%s)" % sub_state)
|
|
|
else:
|
|
|
LOGGER.info(_("No subscriptions added yet, add one!"))
|
|
|
+
|
|
|
+
|
|
|
+def delete_subscription(database, sub_id):
|
|
|
+ """
|
|
|
+ Deletes a specified subscription from the database
|
|
|
+
|
|
|
+ :param database: database object
|
|
|
+ :type database: lib_stov.database.Db
|
|
|
+ :param sub_id: ID of the subscription to be deleted
|
|
|
+ :type sub_id: int
|
|
|
+ """
|
|
|
+ try:
|
|
|
+ database.delete_subscription(sub_id)
|
|
|
+ except stov_exceptions.SubscriptionNotFoundException as error:
|
|
|
+ LOGGER.error(error)
|
|
|
+ sys.exit(1)
|
|
|
+ except stov_exceptions.DBWriteAccessFailedException as error:
|
|
|
+ LOGGER.error(error)
|
|
|
+ sys.exit(1)
|
|
|
+ else:
|
|
|
+ LOGGER.info(_("Subscription deleted successfully!"))
|