Skip to content

Commit

Permalink
Support more magazine url formats
Browse files Browse the repository at this point in the history
  • Loading branch information
ping committed Jul 7, 2023
1 parent 99c88a4 commit 8b20fd7
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions calibre-plugin/dialog/magazines.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,16 @@
from ..libby.client import LibbyFormats, LibbyMediaTypes
from ..model import get_media_title, LibbyMagazinesModel, LibbyCardsModel, LibbyModel

LIBBY_SHARE_URL_RE = re.compile(
r"https://share\.libbyapp\.com/title/(?P<title_id>\d+)\b", re.IGNORECASE
)
LIBBY_URL_RE = re.compile(
r"https://libbyapp.com/library/.+/(.*/)?page-\d+/(?P<title_id>\d+)\b", re.IGNORECASE
)
OVERDRIVE_URL_RE = re.compile(
r"https://(.+)?overdrive.com/(.*/)?media/(?P<title_id>\d+)\b", re.IGNORECASE
)

load_translations()

gui_libby_borrow_hold = LibbyBorrowHold()
Expand Down Expand Up @@ -266,10 +276,10 @@ def borrowed_magazine(self, job):

def add_magazine_btn_clicked(self):
share_url = self.magazine_link_txt.text().strip()
mobj = re.match(
r"https:\/\/share\.libbyapp\.com\/title\/(?P<title_id>\d+)",
share_url,
re.IGNORECASE,
mobj = (
LIBBY_SHARE_URL_RE.match(share_url)
or LIBBY_URL_RE.match(share_url)
or OVERDRIVE_URL_RE.match(share_url)
)
if not mobj:
return error_dialog(self, _("Add Magazine"), _("Invalid URL"), show=True)
Expand Down

0 comments on commit 8b20fd7

Please sign in to comment.