import re
from calibre.web.feeds.news import BasicNewsRecipe

class AdvancedUserRecipe1330393641(BasicNewsRecipe):
     title          = u'JAAPA'
     __author__ = 'adoucette'
     language = 'en'
     oldest_article = 30
     max_articles_per_feed = 100
     auto_cleanup = True

     def get_cover_url(self):
         cover_url = None
         soup = self.index_to_soup('http://www.jaapa.com')
         cover_item = soup.find('img', src=re.compile(r'\w*?cover\w{1,22}\.jpg'))
         if cover_item:
             cover_url = cover_item['src']
         return cover_url

     feeds          = [
             (u'CME Articles',
                 u'http://feeds.feedburner.com/jaapacmearticles'),
             (u'A Day in the Life',
                     u'http://www.jaapa.com/pages/rss.aspx?sectionid=490'),
                 (u'Ask A Librarian',
                     u'http://www.jaapa.com/pages/rss.aspx?sectionid=847'),
                 (u'Case of the Month',
                     u'http://feeds.feedburner.com/jaapacaseofthemonth'),
                 (u'Clinical Watch',
                     u'http://feeds.feedburner.com/jaapaclinicalwatch'),
                 (u'Commentary',
                     u'http://feeds.feedburner.com/jaapacommentary'),
                 (u'Critically Appraised Topic',
                     u'http://www.jaapa.com/pages/rss.aspx?sectionid=699'),
                 (u'Dermatology Digest',
                     u'http://feeds.feedburner.com/jaapadermatologydigest'),
                 (u'Diagnostic Imaging Review',
                     u'http://feeds.feedburner.com/jaapadiagnosticimagingreview'),
                 (u'Editorial',
                     u'http://www.jaapa.com/pages/rss.aspx?sectionid=759'),
                 (u'From the Academy',
                     u'http://feeds.feedburner.com/jaapafromtheacademy'),
                 (u'Genomics in PA Practice',
                     u'http://www.jaapa.com/pages/rss.aspx?sectionid=760'),
                 (u'Humane Medicine',
                     u'http://www.jaapa.com/pages/rss.aspx?sectionid=758'),
                 (u'Inside the AAPA Policy Manual',
                     u'http://www.jaapa.com/pages/rss.aspx?sectionid=1546'),
                 (u'Interpreting ECGs',
                     u'http://www.jaapa.com/pages/rss.aspx?sectionid=1624'),
                 (u'Letters',
                     u'http://www.jaapa.com/pages/rss.aspx?sectionid=808'),
                 (u'PA Quandaries',
                     u'http://www.jaapa.com/pages/rss.aspx?sectionid=496'),
                 (u'Pharmacology Consult',
                     u'http://www.jaapa.com/pages/rss.aspx?sectionid=1614'),
                 (u'POEMs', u'http://feeds.feedburner.com/jaapapoems'),
                 (u'Quick Recertification',
                     u'http://feeds.feedburner.com/jaapaquickrecertificationseries'),
                 (u'Sounding Board',
                     u'http://www.jaapa.com/pages/rss.aspx?sectionid=698'),
                 (u'The Surgical Patient',
                     u'http://www.jaapa.com/pages/rss.aspx?sectionid=499'),
                 (u'Topics in Infectious Diseases',
                     u'http://www.jaapa.com/pages/rss.aspx?sectionid=2495'),
                 (u"What's New", u'http://feeds.feedburner.com/jaapawhatsnew'),
                 (u'When the Patient Asks',
                     u'http://www.jaapa.com/pages/rss.aspx?sectionid=501'),
                 (u"Women's Health",
                     u'http://www.jaapa.com/pages/rss.aspx?sectionid=2176'),
                 (u'AAPA Special Article',
                         u'http://www.jaapa.com/pages/rss.aspx?sectionid=1453'),
                 (u'Case Reports',
                         u'http://feeds.feedburner.com/jaapacasereports'),
                 (u'Review Articles',
                         u'http://feeds.feedburner.com/jaapareviewarticles'),
                 (u'Surgical Reviews',
                         u'http://www.jaapa.com/pages/rss.aspx?sectionid=505'),
                 (u'Brief Report',
                         u'http://www.jaapa.com/pages/rss.aspx?sectionid=2353'),
                 (u'Research Corner',
                         u'http://www.jaapa.com/pages/rss.aspx?sectionid=498'),
                 (u'Research Reports',
                         u'http://www.jaapa.com/pages/rss.aspx?sectionid=1024'),
                 (u'The Art of Medicine',
                         u'http://www.jaapa.com/pages/rss.aspx?sectionid=1289'),
                 (u'Clinical Practice Guidelines',
                         u'http://www.jaapa.com/pages/rss.aspx?sectionid=2102'),
                 (u'Complementary and Alternative Medicine',
                         u'http://www.jaapa.com/pages/rss.aspx?sectionid=2123'),
                 (u'Drug Information',
                         u'http://www.jaapa.com/pages/rss.aspx?sectionid=2089'),
                 (u'Evidence-Based Medicine',
                         u'http://www.jaapa.com/pages/rss.aspx?sectionid=1288'),
                 (u'Patient Information',
                         u'http://www.jaapa.com/pages/rss.aspx?sectionid=2122')]

     def print_version(self, url):
        return url.replace('/article/', '/printarticle/')
