"""
Scraper for Massachusetts Appeals Court
CourtID: massapp
Court Short Name: MS
Author: William Palin
Court Contact: SJCReporter@sjc.state.ma.us (617) 557-1030
Reviewer:
Date: 2020-01-17
"""

from juriscraper.opinions.united_states.state import mass


class Site(mass.Site):
    def __init__(self, *args, **kwargs):
        super(Site, self).__init__(*args, **kwargs)
        self.url = "https://128archive.com"
        self.court_id = self.__module__
        self.court_identifier = "AC"
        self.set_local_variables()
        # https://128archive.com/Disposition/DownloadDisposition/{1 thru 14291}?dispositionId=14304

@@ -73,17 +73,26 @@
  Name: M
-S
+ass App Ct
 %0AAuthor:
@@ -190,11 +190,11 @@
 20-0
-1-1
+2-2
 7%0A%22%22
@@ -205,60 +205,148 @@
 rom 
-juriscraper.opinions.united_states.state import mass
+datetime import date, timedelta%0Afrom juriscraper.OpinionSite import OpinionSite%0Afrom juriscraper.lib.string_utils import convert_date_string
 %0A%0A%0Ac
@@ -359,13 +359,15 @@
 ite(
-mass.
+Opinion
 Site
@@ -479,11 +479,16 @@
 elf.
-url
+homepage
  = %22
@@ -529,202 +529,1715 @@
 lf.c
-ourt_id = self.__module__%0A        self.court_identifier = %22AC%22%0A        self.set_local_variables()%0A        # https://128archive.com/Disposition/DownloadDisposition/%7B1 thru 14291%7D?dispositionId=14304
+ase_date = date.today()%0A        self.backwards_days = 14%0A        self.url = self.build_url()%0A        self.court_id = self.__module__%0A        self.court_identifier = %22AC%22%0A%0A    def build_url(self):%0A        start_date = self.case_date - timedelta(days=self.backwards_days)%0A        url_template = 'https://128archive.com/?Action=search&DocketNumber=&PartyName=&ReleaseDateFrom=%25s&ReleaseDateTo=%25s&Keywords=&SortColumnName=Release+Date+Descending+Order&SortColumnName=Release+Date+Descending+Order&SortOrder=&CurrentPageNo=1&Pages=1&PageSize=100'%0A        return url_template %25 (start_date.strftime(%22%25m/%25d/%25Y%22), self.case_date.strftime(%22%25m/%25d/%25Y%22))%0A%0A    def _download(self, request_dict=%7B%7D):%0A        html = super(Site, self)._download(request_dict)%0A        return html%0A%0A    def _get_download_urls(self):%0A        return %5Blink.get(%22href%22) for link in self.html.xpath('.//a%5Btext()=%22Download PDF%22%5D')%5D%0A%0A    def _get_case_names(self):%0A        xp = './/div%5Bcontains(text(),%22Case Name%22)%5D/following-sibling::div%5B1%5D'%0A        return %5Bcase_name.text_content().strip() for case_name in self.html.xpath(xp)%5D%0A%0A    def _get_case_dates(self):%0A        xp = './/div%5Bcontains(text(),%22Release Date%22)%5D/following-sibling::div%5B1%5D'%0A        return %5Bconvert_date_string(case_date.text_content().strip()) for case_date in self.html.xpath(xp)%5D%0A%0A    def _get_precedential_statuses(self):%0A        xp = './/div%5Bcontains(text(),%22Case Name%22)%5D/following-sibling::div%5B1%5D'%0A        return %5B%22Persuasive%22 for case_name in self.html.xpath(xp)%5D%0A%0A    def _get_docket_numbers(self):%0A        xp = './/div%5Bcontains(text(),%22Docket Number%22)%5D/following-sibling::div%5B1%5D'%0A        return %5Bdocket_number.text_content().strip() for docket_number in self.html.xpath(xp)%5D%0A
 %0A

Add Mass Appeals court 128 decisions