# Path: shiori/bookmark/agents/feed_parser.py
# class FeedParser(object):
#     """ FeedParser class """
# 
#     def __init__(self, url):
#         try:
#             response = requests.get(url, stream=True)
#         except requests.ConnectionError as error:
#             print(error)
#             sys.exit(1)
#         try:
#             etree = lxml.fromstring(response.content)
#         except XMLSyntaxError as error:
#             print(error)
#             sys.exit(1)
#         self.nsmap = etree.nsmap
#         self.namespace = get_ns(etree.nsmap, None)
# 
#         self.updated = get_updated(etree, self.nsmap)
#         self.title = get_title(etree, self.namespace)
#         self.items = get_items(etree, self.namespace)
#         self.etree = etree
# 
#     def retrieve_items(self):
#         """ retrieve feed items """
#         return [dict(title=get_title(item, self.namespace),
#                      link=get_link(item, self.namespace),
#                      updated=get_updated(item, self.nsmap))
#                 for item in self.items]
# 
# Path: shiori/bookmark/validators.py
# def validate_url(value):
# def getaddr(hostname):


from django.db import models
from django.db.models.signals import pre_save
from django.contrib.auth.models import User
from shortuuidfield import ShortUUIDField
from pyquery import PyQuery
from shiori.bookmark.agents.feed_parser import FeedParser
from shiori.bookmark import validators
import jsonfield
    registered_datetime = models.DateTimeField(auto_now=True,
                                               auto_now_add=True)
    description = models.TextField(blank=True)
    owner = models.ForeignKey(User)
    is_hide = models.BooleanField(default=False)

    class Meta(object):
        """ meta class """
        db_table = 'bookmark'
        unique_together = ('url', 'owner')

    def __unicode__(self):
        return self.title

    def get_absolute_url(self):
        """ bookmark permalink path """
        return "/shiori/b/%s" % self.id


def retrieve_title(sender, instance, **kwargs):
    """ Retreive title of specified url.

    Arguments:
        sender: :model (Bookmark)
        instance: Bookmark instance
        **kwargs: not use
    """
    if instance.title:
        return instance.title
    else:

# Path: shiori/bookmark/agents/feed_parser.py
# class FeedParser(object):
#     """ FeedParser class """
# 
#     def __init__(self, url):
#         try:
#             response = requests.get(url, stream=True)
#         except requests.ConnectionError as error:
#             print(error)
#             sys.exit(1)
#         try:
#             etree = lxml.fromstring(response.content)
#         except XMLSyntaxError as error:
#             print(error)
#             sys.exit(1)
#         self.nsmap = etree.nsmap
#         self.namespace = get_ns(etree.nsmap, None)
# 
#         self.updated = get_updated(etree, self.nsmap)
#         self.title = get_title(etree, self.namespace)
#         self.items = get_items(etree, self.namespace)
#         self.etree = etree
# 
#     def retrieve_items(self):
#         """ retrieve feed items """
#         return [dict(title=get_title(item, self.namespace),
#                      link=get_link(item, self.namespace),
#                      updated=get_updated(item, self.nsmap))
#                 for item in self.items]
# 
# Path: shiori/bookmark/validators.py
# def validate_url(value):
# def getaddr(hostname):


# Path: shiori/bookmark/models.py
from django.db import models
from django.db.models.signals import pre_save
from django.contrib.auth.models import User
from shortuuidfield import ShortUUIDField
from pyquery import PyQuery
from shiori.bookmark.agents.feed_parser import FeedParser
from shiori.bookmark import validators
import jsonfield

    registered_datetime = models.DateTimeField(auto_now=True,
                                               auto_now_add=True)
    description = models.TextField(blank=True)
    owner = models.ForeignKey(User)
    is_hide = models.BooleanField(default=False)

    class Meta(object):
        """ meta class """
        db_table = 'bookmark'
        unique_together = ('url', 'owner')

    def __unicode__(self):
        return self.title

    def get_absolute_url(self):
        """ bookmark permalink path """
        return "/shiori/b/%s" % self.id


def retrieve_title(sender, instance, **kwargs):
    """ Retreive title of specified url.

    Arguments:
        sender: :model (Bookmark)
        instance: Bookmark instance
        **kwargs: not use
    """
    if instance.title:
        return instance.title
    else:

        if validators.validate_url(instance.url):