From 84e76301ed9f474e735599ddb69141b64fac66dc Mon Sep 17 00:00:00 2001 From: jake Date: Fri, 6 Jan 2023 11:41:14 -0800 Subject: [PATCH] added support for deleting reviews by itemname --- internetarchive/cli/ia_reviews.py | 8 ++++++-- internetarchive/item.py | 4 +++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/internetarchive/cli/ia_reviews.py b/internetarchive/cli/ia_reviews.py index a1b25593..d06de76d 100644 --- a/internetarchive/cli/ia_reviews.py +++ b/internetarchive/cli/ia_reviews.py @@ -25,7 +25,8 @@ usage: ia reviews - ia reviews --delete [--username= | --screenname=] + ia reviews --delete [--username= | --screenname= + | --itemname=] ia reviews --title= --body=<body> [--stars=<stars>] ia reviews --help @@ -39,6 +40,8 @@ given username (must be used with --delete). -S, --screenname=<screenname> Delete reviews for a specific user given screenname (must be used with --delete). + -I, --itemname=<itemname> Delete reviews for a specific user + given itemname (must be used with --delete). examples: ia reviews nasa @@ -57,7 +60,8 @@ def main(argv, session: ArchiveSession) -> None: item = session.get_item(args['<identifier>']) if args['--delete']: r = item.delete_review(username=args['--username'], - screenname=args['--screenname']) + screenname=args['--screenname'], + itemname=args['--itemname']) elif not args['--body']: try: r = item.get_review() diff --git a/internetarchive/item.py b/internetarchive/item.py index 393c84af..7142eb77 100644 --- a/internetarchive/item.py +++ b/internetarchive/item.py @@ -493,7 +493,7 @@ def get_review(self) -> Response: r.raise_for_status() return r - def delete_review(self, username=None, screenname=None) -> Response: + def delete_review(self, username=None, screenname=None, itemname=None) -> Response: u = f'{self.session.protocol}//{self.session.host}/services/reviews.php' p = {'identifier': self.identifier} d = None @@ -501,6 +501,8 @@ def delete_review(self, username=None, screenname=None) -> Response: d = {'username': username} elif screenname: d = {'screenname': screenname} + elif itemname: + d = {'itemname': itemname} a = S3Auth(self.session.access_key, self.session.secret_key) r = self.session.delete(u, params=p, data=d, auth=a) r.raise_for_status()