From ac089c444df7861545d36d251bc904316ce0991a Mon Sep 17 00:00:00 2001 From: unkn0w7n <51942695+unkn0w7n@users.noreply.github.com> Date: Sun, 7 Jul 2024 10:23:25 +0530 Subject: [PATCH 1/3] World Archaeology Magazine --- recipes/icons/world_archeology.png | Bin 0 -> 382 bytes recipes/military_history.recipe | 9 +-- recipes/world_archeology.recipe | 100 +++++++++++++++++++++++++++++ 3 files changed, 105 insertions(+), 4 deletions(-) create mode 100644 recipes/icons/world_archeology.png create mode 100644 recipes/world_archeology.recipe diff --git a/recipes/icons/world_archeology.png b/recipes/icons/world_archeology.png new file mode 100644 index 0000000000000000000000000000000000000000..39a11410c8a3bdbe30d16c4065570962b9da5294 GIT binary patch literal 382 zcmV-^0fGLBP)+yt% zr_|Qr00UE)oU*2=z5oeSM^1ap&f9Ktlr%kXEH`Zc094@N=>Pynprf?_09Wtu^tQRk ztF66NTZBteep+9I002NdM00d`l;W&<)c^nhxJg7oR2Y?Ik8N**Fc5>!mp2j;0!=A} zwvBo#54Xf#PlHS4Nal5KZL$Nn_9^Eg!n zyC7U~8|OPDvMq(ByA8O^;sJ)&MA|zYXC<(AYMo;VoUgU(u^!yAVfYDbPH7yoZ&7}z z3u0RM4Ixe9qahP;G*6s*JjIG&3WM~D2oo$m-B#{4yMO6?-ZL-pt2CGz+mK|oEU7a5 cKJNegZ*Er#c3AY%mjD0&07*qoM6N<$f*9MLvH$=8 literal 0 HcmV?d00001 diff --git a/recipes/military_history.recipe b/recipes/military_history.recipe index 46882e27f9..3f6565e611 100644 --- a/recipes/military_history.recipe +++ b/recipes/military_history.recipe @@ -57,10 +57,11 @@ class milthist(BasicNewsRecipe): if dt: self.timefmt = ' [' + self.tag_to_string(dt).strip() + ']' edit = issue.find('h2', attrs={'id':'from-the-editor'}) - if edit.findNext('p'): - self.description = self.tag_to_string(edit.findNext('p')) - if edit.findPrevious('figure'): - self.cover_url = edit.findPrevious('figure').img['src'] + if edit and edit.findParent('div'): + self.description = self.tag_to_string(edit.findParent('div')) + cov = issue.find('figure', attrs={'class':lambda x: x and 'wp-block-image' in x.split()}) + if cov: + self.cover_url = cov.img['src'] div = issue.find('div', attrs={'class':lambda x: x and 'entry-content' in x.split()}) feeds = [] diff --git a/recipes/world_archeology.recipe b/recipes/world_archeology.recipe new file mode 100644 index 0000000000..9a17b1e75a --- /dev/null +++ b/recipes/world_archeology.recipe @@ -0,0 +1,100 @@ +''' +https://www.world-archaeology.com +''' +from calibre import browser +from calibre.web.feeds.news import BasicNewsRecipe + +class worldarch(BasicNewsRecipe): + title = 'Current World Archaeology' + language = 'en' + __author__ = 'unkn0wn' + description = ( + 'Travel the globe with Current World Archaeology, the magazine that brings you up-to-date with the latest archaeological discoveries. ' + 'Explore sites – and sights – through our exclusive features and eye-popping photography. We bring you the stories from the ' + 'archaeologists themselves, so you learn first-hand from the experts about the latest finds and most up-to-date research. ' + 'Published six times a year.' + ) + no_stylesheets = True + use_embedded_content = False + remove_attributes = ['style', 'height', 'width'] + ignore_duplicate_articles = {'url'} + resolve_internal_links = True + masthead_url = 'https://i0.wp.com/www.world-archaeology.com/wp-content/uploads/2016/02/cwa-logo.png' + simultaneous_downloads = 1 + + extra_css = ''' + [class^="meta"] { font-size:small; } + .post-subtitle { font-style: italic; color:#202020; } + .wp-block-image { font-size:small; text-align:center; } + ''' + + keep_only_tags = [ + dict(attrs={'class':lambda x: x and '__header' in x}), + dict(attrs={'class':lambda x: x and '__background' in x}), + dict(attrs={'class':lambda x: x and '__body_area' in x}), + ] + + remove_tags = [ + dict(attrs={'class':'ad-break'}), + dict(attrs={'class':lambda x: x and 'avatar' in x.split()}), + dict(attrs={'class':lambda x: x and '--share' in x}) + ] + + def preprocess_html(self, soup): + exp = soup.find(attrs={'class':lambda x: x and 'post-subtitle' in x.split()}) + if exp: + exp.name = 'p' + return soup + + def parse_index(self): + soup = self.index_to_soup('https://the-past.com/category/magazines/cwa/') + art = soup.find('article', attrs={'class':lambda x: x and 'tag-magazines' in x.split()}) + url = art.h2.a['href'] + + # for past editions, add url + # url = '' + + issue = self.index_to_soup(url) + dt = soup.find(attrs={'class':lambda x: x and '__date' in x}) + if dt: + self.timefmt = ' [' + self.tag_to_string(dt).strip() + ']' + edit = issue.find('h2', attrs={'id':'from-the-editor'}) + if edit and edit.findParent('div'): + self.description = self.tag_to_string(edit.findParent('div')) + cov = issue.find('figure', attrs={'class':lambda x: x and 'wp-block-image' in x.split()}) + if cov: + self.cover_url = cov.img['src'] + div = issue.find('div', attrs={'class':lambda x: x and 'entry-content' in x.split()}) + + feeds = [] + + h2 = div.findAll('h2', attrs={'class':lambda x: x and 'wp-block-heading' in x.split()}) + lt = div.findAll(attrs={'class':'display-posts-listing'}) + for x, y in zip(h2, lt): + section = self.tag_to_string(x).strip() + self.log(section) + articles = [] + for a in y.findAll('a', href=True, attrs={'class':'title'}): + url = a['href'] + title = self.tag_to_string(a).strip() + desc = '' + exp = a.findNext(attrs={'class':'excerpt'}) + if exp: + desc = self.tag_to_string(exp).strip() + self.log('\t', title, '\n\t', desc, '\n\t\t', url) + articles.append({'title': title, 'description':desc, 'url': url}) + if articles: + feeds.append((section, articles)) + return feeds + + def get_browser(self, *args, **kwargs): + return self + + def clone_browser(self, *args, **kwargs): + return self.get_browser() + + def open_novisit(self, *args, **kwargs): + br = browser() + return br.open_novisit(*args, **kwargs) + + open = open_novisit From 17b6b6ad5e7e4fee861160554334ea3c38f8cb03 Mon Sep 17 00:00:00 2001 From: unkn0w7n <51942695+unkn0w7n@users.noreply.github.com> Date: Sun, 7 Jul 2024 10:30:54 +0530 Subject: [PATCH 2/3] Minerva Magazine --- recipes/icons/minerva_magazine.png | Bin 0 -> 380 bytes recipes/military_history.recipe | 5 +- recipes/minerva_magazine.recipe | 102 +++++++++++++++++++++++++++++ recipes/world_archeology.recipe | 5 +- 4 files changed, 110 insertions(+), 2 deletions(-) create mode 100644 recipes/icons/minerva_magazine.png create mode 100644 recipes/minerva_magazine.recipe diff --git a/recipes/icons/minerva_magazine.png b/recipes/icons/minerva_magazine.png new file mode 100644 index 0000000000000000000000000000000000000000..57be82fff8cc3ca7ec3db328df00d75a65d66d55 GIT binary patch literal 380 zcmV-?0fYXDP)h(HN6p^MWLI`}{M@mVj)4_2ZwAQRvEB5<60RQrp&wtRLjSTXd#d$~! aynh02pnAR?^oF$n0000 Date: Sun, 7 Jul 2024 10:32:05 +0530 Subject: [PATCH 3/3] Ancient Egypt Magazine --- recipes/ancient_egypt.recipe | 102 ++++++++++++++++++++++++++++++++ recipes/icons/ancient_egypt.png | Bin 0 -> 491 bytes 2 files changed, 102 insertions(+) create mode 100644 recipes/ancient_egypt.recipe create mode 100644 recipes/icons/ancient_egypt.png diff --git a/recipes/ancient_egypt.recipe b/recipes/ancient_egypt.recipe new file mode 100644 index 0000000000..defbda1b45 --- /dev/null +++ b/recipes/ancient_egypt.recipe @@ -0,0 +1,102 @@ +''' +https://ancientegyptmagazine.com +''' +from calibre import browser +from calibre.web.feeds.news import BasicNewsRecipe + +class ancientegypt(BasicNewsRecipe): + title = 'The Past: Ancient Egypt Magazine' + language = 'en' + __author__ = 'unkn0wn' + description = ( + 'Ancient Egypt is the world\'s leading Egyptology magazine, exploring the history, people and culture of the Nile Valley. ' + 'Now in a larger format with a fresh new design, AE brings you the latest news and discoveries, and feature articles covering ' + 'more than 5000 years of Egyptian history. Published bimonthly.' + ) + no_stylesheets = True + use_embedded_content = False + remove_attributes = ['style', 'height', 'width'] + ignore_duplicate_articles = {'url'} + resolve_internal_links = True + masthead_url = 'https://ancientegyptmagazine.com/media/website/ae-logo-2.png' + simultaneous_downloads = 1 + + extra_css = ''' + [class^="meta"] { font-size:small; } + .post-subtitle { font-style: italic; color:#202020; } + .wp-block-image { font-size:small; text-align:center; } + ''' + + keep_only_tags = [ + dict(attrs={'class':lambda x: x and '__header' in x}), + dict(attrs={'class':lambda x: x and '__background' in x}), + dict(attrs={'class':lambda x: x and '__body_area' in x}), + ] + + remove_tags = [ + dict(attrs={'class':'ad-break'}), + dict(attrs={'class':lambda x: x and 'avatar' in x.split()}), + dict(attrs={'class':lambda x: x and '--share' in x}) + ] + + def preprocess_html(self, soup): + exp = soup.find(attrs={'class':lambda x: x and 'post-subtitle' in x.split()}) + if exp: + exp.name = 'p' + return soup + + def parse_index(self): + soup = self.index_to_soup('https://the-past.com/category/magazines/ae/') + art = soup.find('article', attrs={'class':lambda x: x and 'tag-magazines' in x.split()}) + url = art.h2.a['href'] + + # for past editions, add url + # url = '' + + issue = self.index_to_soup(url) + ti = issue.find('h1', attrs={'class':lambda x: x and 'post-title' in x.split()}) + if ti: + self.title = self.tag_to_string(ti).strip() + dt = soup.find(attrs={'class':lambda x: x and '__date' in x}) + if dt: + self.timefmt = ' [' + self.tag_to_string(dt).strip() + ']' + edit = issue.find('h2', attrs={'id':'from-the-editor'}) + if edit and edit.findParent('div'): + self.description = self.tag_to_string(edit.findParent('div')) + cov = issue.find('figure', attrs={'class':lambda x: x and 'wp-block-image' in x.split()}) + if cov: + self.cover_url = cov.img['src'] + div = issue.find('div', attrs={'class':lambda x: x and 'entry-content' in x.split()}) + + feeds = [] + + h2 = div.findAll('h2', attrs={'class':lambda x: x and 'wp-block-heading' in x.split()}) + lt = div.findAll(attrs={'class':'display-posts-listing'}) + for x, y in zip(h2, lt): + section = self.tag_to_string(x).strip() + self.log(section) + articles = [] + for a in y.findAll('a', href=True, attrs={'class':'title'}): + url = a['href'] + title = self.tag_to_string(a).strip() + desc = '' + exp = a.findNext(attrs={'class':'excerpt'}) + if exp: + desc = self.tag_to_string(exp).strip() + self.log('\t', title, '\n\t', desc, '\n\t\t', url) + articles.append({'title': title, 'description':desc, 'url': url}) + if articles: + feeds.append((section, articles)) + return feeds + + def get_browser(self, *args, **kwargs): + return self + + def clone_browser(self, *args, **kwargs): + return self.get_browser() + + def open_novisit(self, *args, **kwargs): + br = browser() + return br.open_novisit(*args, **kwargs) + + open = open_novisit diff --git a/recipes/icons/ancient_egypt.png b/recipes/icons/ancient_egypt.png new file mode 100644 index 0000000000000000000000000000000000000000..e74f750c22d400a8c6d74546cfef269bb5beda7a GIT binary patch literal 491 zcmVwFm(%jlkce%urLgTE4k2!}k!yqCHBGQomuZD;$C=qD@U36Bi5)tW8 z41n(;_-a{1$Hq`fHCd%l;9I%eChkop(GTISX;L~kXkp!kft5~UrPH{MgX=iFUtQ(O zwp$Zi9v$Hi1juJHBqk@D{7EE2C>}>^&EU)o0HJuCKsel*;5eIQ$}~CO+vCUG-9L8^ zMWYyrglF)xUgvwYN^EqL-jNYLZf>@TZb~Iix3+k@yv&F7bpX%6-r3>#&=A)b7xYa` zkY8JCGf-Ni{eG0s+q~JGZg2Bqc$mV*1_0HwGp=l#X9ELX>{yIf)6)Prm5OIjD;DWC z3{vy+&EZ@2~a9_qCk$Js21ptR;`e?L{*Zc7nKCVBKLYruVk h-qpZjhbAtt_y?wp*9X@VVf6q2002ovPDHLkV1m%l;yM5T literal 0 HcmV?d00001