# Copyright (c) 2014, Joshua Stone
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice, this
#   list of conditions and the following disclaimer.
#
# * Redistributions in binary form must reproduce the above copyright notice,
#   this list of conditions and the following disclaimer in the documentation
#   and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

class Watched(object):
  def __init__(self, key, page=1, perpage=15, comments=False, fav=False):
    self.__parameters = {}
    self.key = key
    self.page = page
    self.perpage = perpage
    self.comments = comments
    self.fav = fav

  @property
  def hostname(self):
    return("https://derpiboo.ru")

  @property
  def key(self):
    return(self.parameters["key"])

  @key.setter
  def key(self, key=""):
    if not isinstance(key, str):
      raise TypeError("key must be a string")

    self.__parameters["key"] = key

  @property
  def page(self):
    return(self.parameters["page"])

  @page.setter
  def page(self, page=1):
    if not isinstance(page, int):
      raise TypeError("page number must be an int")

    if page < 1:
      raise ValueError("page number must be greater than 0")

    self.__parameters["page"] = page

  def next_page(self, number=1):
    if not isinstance(number, int):
      raise TypeError("page number must be an int")

    if number < 1:
      raise ValueError("page number must be greater than 0")

    self.__parameters["page"] += number

  def previous_page(self, number=1):
    if not isinstance(number, int):
      raise TypeError("page number must be an int")

    if number < 1:
      raise ValueError("page number must be greater than 0")

    if self.parameters["page"] - number <= 1:
      self.__parameters["page"] = 1
    else:
      self.__parameters["page"] -= number

  @property
  def perpage(self):
    return(self.parameters["perpage"])

  @perpage.setter
  def perpage(self, page_size):
    if not isinstance(page_size, int):
      raise TypeError("perpage must be an int")
    if page_size not in range(1, 51):
      raise ValueError("perpage must be within range of 1-50")

    self.__parameters["perpage"] = page_size

  @property
  def comments(self):
    return(self.parameters["comments"])

  @comments.setter
  def comments(self, comments=True):
    if not isinstance(comments, bool):
      raise TypeError("comments must be either True or False")

    self.__parameters["comments"] = comments

  @property
  def fav(self):
    return(self.parameters["fav"])

  @fav.setter
  def fav(self, fav=True):
    if not isinstance(fav, bool):
      raise TypeError("favorites must be either True or False")

    self.__parameters["fav"] = fav

  @property
  def parameters(self):
    return(self.__parameters)

  @property
  def url(self):
    url, parameters = self.hostname + "/images/watched.json", []
    
    parameters.append("key={0}".format(self.key))
    parameters.append("perpage={0}".format(self.perpage))
    parameters.append("page={0}".format(self.page))

    if self.comments == True:
      parameters.append("comments=")
    if self.fav == True:
      parameters.append("fav=")

    url += "?{0}".format("&".join(parameters))

    return(url)

  @property
  def random(self):
    url = self.hostname + "/images/watched.json?random=y&key=" + self.key

    return(url)

@@ -1331,16 +1331,40 @@
 AMAGE.%0A%0A
+from .user import User%0A%0A
 class Wa
@@ -1373,14 +1373,12 @@
 hed(
-object
+User
 ):%0A 
@@ -1458,2277 +1458,61 @@
     
-self.__parameters = %7B%7D%0A    self.key = key%0A    self.page = page%0A    self.perpage = perpage%0A    self.comments = comments%0A    self.fav = fav%0A%0A  @property%0A  def hostname(self):%0A    return(%22https://derpiboo.ru%22)%0A%0A  @property%0A  def key(self):%0A    return(self.parameters%5B%22key%22%5D)%0A%0A  @key.setter%0A  def key(self, key=%22%22):%0A    if not isinstance(key, str):%0A      raise TypeError(%22key must be a string%22)%0A%0A    self.__parameters%5B%22key%22%5D = key%0A%0A  @property%0A  def page(self):%0A    return(self.parameters%5B%22page%22%5D)%0A%0A  @page.setter%0A  def page(self, page=1):%0A    if not isinstance(page, int):%0A      raise TypeError(%22page number must be an int%22)%0A%0A    if page %3C 1:%0A      raise ValueError(%22page number must be greater than 0%22)%0A%0A    self.__parameters%5B%22page%22%5D = page%0A%0A  def next_page(self, number=1):%0A    if not isinstance(number, int):%0A      raise TypeError(%22page number must be an int%22)%0A%0A    if number %3C 1:%0A      raise ValueError(%22page number must be greater than 0%22)%0A%0A    self.__parameters%5B%22page%22%5D += number%0A%0A  def previous_page(self, number=1):%0A    if not isinstance(number, int):%0A      raise TypeError(%22page number must be an int%22)%0A%0A    if number %3C 1:%0A      raise ValueError(%22page number must be greater than 0%22)%0A%0A    if self.parameters%5B%22page%22%5D - number %3C= 1:%0A      self.__parameters%5B%22page%22%5D = 1%0A    else:%0A      self.__parameters%5B%22page%22%5D -= number%0A%0A  @property%0A  def perpage(self):%0A    return(self.parameters%5B%22perpage%22%5D)%0A%0A  @perpage.setter%0A  def perpage(self, page_size):%0A    if not isinstance(page_size, int):%0A      raise TypeError(%22perpage must be an int%22)%0A    if page_size not in range(1, 51):%0A      raise ValueError(%22perpage must be within range of 1-50%22)%0A%0A    self.__parameters%5B%22perpage%22%5D = page_size%0A%0A  @property%0A  def comments(self):%0A    return(self.parameters%5B%22comments%22%5D)%0A%0A  @comments.setter%0A  def comments(self, comments=True):%0A    if not isinstance(comments, bool):%0A      raise TypeError(%22comments must be either True or False%22)%0A%0A    self.__parameters%5B%22comments%22%5D = comments%0A%0A  @property%0A  def fav(self):%0A    return(self.parameters%5B%22fav%22%5D)%0A%0A  @fav.setter%0A  def fav(self, fav=True):%0A    if not isinstance(fav, bool):%0A      raise TypeError(%22favorites must be either True or False%22)%0A%0A    self.__parameters%5B%22fav%22%5D = fav%0A%0A  @property%0A  def parameters(self):%0A    return(self.__parameters
+User.__init__(self, key, page, perpage, comments, fav
 )%0A%0A 

Change Watched() to inherit User()