<commit_before># -*- coding: utf-8 -*-
# This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later.
# Copyright © <NAME>. See NOTICE for more information.
#
from django.contrib.sites.models import Site
from django.contrib.syndication.views import Feed
from django.core.urlresolvers import reverse

from catalogue import models

def absolute_url(url):
    return "http://%s%s" % (Site.objects.get_current().domain, url)


class AudiobookFeed(Feed):
    description = "Audiobooki ostatnio dodane do serwisu Wolne Lektury."

    mime_types = {
        'mp3': 'audio/mpeg',
        'ogg': 'audio/ogg',
        'daisy': 'application/zip',
    }

    titles = {
        'all': 'WolneLektury.pl - audiobooki we wszystkich formatach',
        'mp3': 'WolneLektury.pl - audiobooki w formacie MP3',
        'ogg': 'WolneLektury.pl - audiobooki w formacie Ogg Vorbis',
        'daisy': 'WolneLektury.pl - audiobooki w formacie DAISY',
    }

    def get_object(self, request, type):
        return type

    def title(self, type):
        return self.titles[type]

    def link(self, type):
        return reverse('audiobook_feed', args=(type,))

    def items(self, type):
        objects = models.BookMedia.objects.order_by('-uploaded_at')
        if type == 'all':
            objects = objects.filter(type__in=('mp3', 'ogg', 'daisy'))
        else:
            objects = objects.filter(type=type)[:20]
        return objects

    def item_title(self, item):
        return item.name

    def item_description(self, item):
        lines = []
        artist = item.get_extra_info_value().get('artist_name', None)<commit_msg>author as category in audiobook feeds<commit_after># -*- coding: utf-8 -*-
# This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later.
# Copyright © <NAME>. See NOTICE for more information.
#
from django.contrib.sites.models import Site
from django.contrib.syndication.views import Feed
from django.core.urlresolvers import reverse
from django.db.models import Q

from catalogue import models

def absolute_url(url):
    return "http://%s%s" % (Site.objects.get_current().domain, url)


class AudiobookFeed(Feed):
    description = "Audiobooki ostatnio dodane do serwisu Wolne Lektury."

    mime_types = {
        'mp3': 'audio/mpeg',
        'ogg': 'audio/ogg',
        'daisy': 'application/zip',
    }

    titles = {
        'all': 'WolneLektury.pl - audiobooki we wszystkich formatach',
        'mp3': 'WolneLektury.pl - audiobooki w formacie MP3',
        'ogg': 'WolneLektury.pl - audiobooki w formacie Ogg Vorbis',
        'daisy': 'WolneLektury.pl - audiobooki w formacie DAISY',
    }

    def get_object(self, request, type):
        return {'type': type, 'all': 'all' in request.GET}

    def title(self, args):
        return self.titles[args['type']]

    def link(self, args):
        return reverse('audiobook_feed', args=(args['type'],))

    def items(self, args):
        objects = models.BookMedia.objects.order_by('-uploaded_at')
        if type == 'all':
            objects = objects.filter(type__in=('mp3', 'ogg', 'daisy'))
        else:
            objects = objects.filter(type=args['type'])
        if not args['all']:
            objects = objects[:50]
        return objects

    def item_title(self, item):
        return item.name

    def item_categories(self, item):
        authors = set()
        for book in item.book_set.all():
            for author in book.tags.filter(category='author'):
                authors.add(author.name)
        return sorted(authors)

    def item_description(self, item):
        lines = []
        artist = item.get_extra_info_value().get('artist_name', None)
{'fraction_non_alphanumeric': 0.1266304347826087, 'fraction_numerical': 0.004347826086956522, 'mean_word_length': 2.81055900621118, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5412590', 'n_tokens_mistral': 1228, 'n_tokens_neox': 1175, 'n_words': 304}