# Path: djwechat/rss/models.py
# class Article(models.Model):
#     channel = models.ForeignKey(to=FeedChannel,
#                                 verbose_name=_('Feed Channel'))
#     title = models.CharField(verbose_name=_('Title'),
#                              max_length=255)
#     link = models.URLField(verbose_name=_('Link'))
#     authors = models.ManyToManyField(Author,
#                                      verbose_name=_('Authors'))
#     categories = models.ManyToManyField(Category,
#                                         verbose_name=_('Categories'))
#     content = models.TextField(verbose_name=_('Content'))
#     publishedAt = models.DateTimeField(verbose_name=_('Published Time'))
#     updatedAt = models.DateTimeField(verbose_name=_('Updated Time'),
#                                      auto_now=True)
#     show = models.BooleanField(verbose_name=_('Show'),
#                                help_text=_('Whether to show this article'),
#                                default=True)
# 
#     def __str__(self):
#         return self.title
# 
#     class Meta:
#         verbose_name = _('Article')
#         verbose_name_plural = _('Articles')
#         unique_together = (('channel', 'title', 'link'),)
#         ordering = ('-updatedAt', '-publishedAt')
# 
# Path: djwechat/rss/models.py
# class Author(models.Model):
#     name = models.CharField(verbose_name=_('Name'),
#                             max_length=25)
#     link = models.URLField(verbose_name=_('Homepage'),
#                            null=True, blank=True)
# 
#     def __str__(self):
#         return self.name
# 
#     class Meta:
#         verbose_name = _('Author')
#         verbose_name_plural = _('Authors')
#         unique_together = (('name', 'link'),)
# 
# Path: djwechat/rss/models.py
# class Category(models.Model):
#     tag = models.CharField(verbose_name=_('Tag'),
#                            max_length=25,
#                            unique=True)
# 
#     def __str__(self):
#         return self.tag
# 
#     class Meta:
#         verbose_name = _('Category')
#         verbose_name_plural = _('Categories')
# 
# Path: djwechat/rss/models.py
# class FeedChannel(models.Model):
#     title = models.CharField(verbose_name=_('Title'),
#                              max_length=50)
#     link = models.URLField(verbose_name=_('Feed Link'))
#     website = models.URLField(verbose_name=_('Official Website'))
#     subtitle = models.TextField(verbose_name=_('Subtitle'),
#                                 null=True, blank=True)
#     description = models.TextField(verbose_name=_('Description'),
#                                    null=True, blank=True)
# 
#     def __str__(self):
#         return self.title
# 
#     class Meta:
#         verbose_name = _('Feed Channel')
#         verbose_name_plural = _('Feed Channels')
#         unique_together = (('title', 'link'),)
#         ordering = ('title',)


import feedparser
import time
from datetime import datetime
from django.db import IntegrityError
from .models import Article
from .models import Author
from .models import Category
from .models import FeedChannel
                entry.get('published_parsed')))
            article['updated'] = datetime_to_string(struct_to_datetime(
                entry.get('updated_parsed')))

            article['guid'] = entry.get('id', entry.get('link'))
            articles.append(article)
        except IntegrityError:
            pass
    return articles


def get_feed_channel(url):
    channel = get_feed(url)
    feed_channel, _ = FeedChannel.objects.get_or_create(
        title=channel['title'],
        link=channel['link'],
        website=channel['website'],
        subtitle=channel['subtitle'],
        description=channel['description'])
    return feed_channel


def update_articles(url):
    add_num = 0
    articles = get_articles(url)
    feed_channel = get_feed_channel(url)
    for article in articles:
        try:
            authors = []
            for author in article['authors']:

# Path: djwechat/rss/models.py
# class Article(models.Model):
#     channel = models.ForeignKey(to=FeedChannel,
#                                 verbose_name=_('Feed Channel'))
#     title = models.CharField(verbose_name=_('Title'),
#                              max_length=255)
#     link = models.URLField(verbose_name=_('Link'))
#     authors = models.ManyToManyField(Author,
#                                      verbose_name=_('Authors'))
#     categories = models.ManyToManyField(Category,
#                                         verbose_name=_('Categories'))
#     content = models.TextField(verbose_name=_('Content'))
#     publishedAt = models.DateTimeField(verbose_name=_('Published Time'))
#     updatedAt = models.DateTimeField(verbose_name=_('Updated Time'),
#                                      auto_now=True)
#     show = models.BooleanField(verbose_name=_('Show'),
#                                help_text=_('Whether to show this article'),
#                                default=True)
# 
#     def __str__(self):
#         return self.title
# 
#     class Meta:
#         verbose_name = _('Article')
#         verbose_name_plural = _('Articles')
#         unique_together = (('channel', 'title', 'link'),)
#         ordering = ('-updatedAt', '-publishedAt')
# 
# Path: djwechat/rss/models.py
# class Author(models.Model):
#     name = models.CharField(verbose_name=_('Name'),
#                             max_length=25)
#     link = models.URLField(verbose_name=_('Homepage'),
#                            null=True, blank=True)
# 
#     def __str__(self):
#         return self.name
# 
#     class Meta:
#         verbose_name = _('Author')
#         verbose_name_plural = _('Authors')
#         unique_together = (('name', 'link'),)
# 
# Path: djwechat/rss/models.py
# class Category(models.Model):
#     tag = models.CharField(verbose_name=_('Tag'),
#                            max_length=25,
#                            unique=True)
# 
#     def __str__(self):
#         return self.tag
# 
#     class Meta:
#         verbose_name = _('Category')
#         verbose_name_plural = _('Categories')
# 
# Path: djwechat/rss/models.py
# class FeedChannel(models.Model):
#     title = models.CharField(verbose_name=_('Title'),
#                              max_length=50)
#     link = models.URLField(verbose_name=_('Feed Link'))
#     website = models.URLField(verbose_name=_('Official Website'))
#     subtitle = models.TextField(verbose_name=_('Subtitle'),
#                                 null=True, blank=True)
#     description = models.TextField(verbose_name=_('Description'),
#                                    null=True, blank=True)
# 
#     def __str__(self):
#         return self.title
# 
#     class Meta:
#         verbose_name = _('Feed Channel')
#         verbose_name_plural = _('Feed Channels')
#         unique_together = (('title', 'link'),)
#         ordering = ('title',)


# Path: djwechat/rss/parser.py
import feedparser
import time
from datetime import datetime
from django.db import IntegrityError
from .models import Article
from .models import Author
from .models import Category
from .models import FeedChannel

                entry.get('published_parsed')))
            article['updated'] = datetime_to_string(struct_to_datetime(
                entry.get('updated_parsed')))

            article['guid'] = entry.get('id', entry.get('link'))
            articles.append(article)
        except IntegrityError:
            pass
    return articles


def get_feed_channel(url):
    channel = get_feed(url)
    feed_channel, _ = FeedChannel.objects.get_or_create(
        title=channel['title'],
        link=channel['link'],
        website=channel['website'],
        subtitle=channel['subtitle'],
        description=channel['description'])
    return feed_channel


def update_articles(url):
    add_num = 0
    articles = get_articles(url)
    feed_channel = get_feed_channel(url)
    for article in articles:
        try:
            authors = []
            for author in article['authors']:

                a, _ = Author.objects.get_or_create(