Let publishers configure episode slugs
[mygpo.git] / mygpo / data / podcast.py
blobf51cee61169cec5d40cc92e432cd2ce0d702b26a
2 # This file is part of my.gpodder.org.
4 # my.gpodder.org is free software: you can redistribute it and/or modify it
5 # under the terms of the GNU Affero General Public License as published by
6 # the Free Software Foundation, either version 3 of the License, or (at your
7 # option) any later version.
9 # my.gpodder.org is distributed in the hope that it will be useful, but
10 # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
11 # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
12 # License for more details.
14 # You should have received a copy of the GNU Affero General Public License
15 # along with my.gpodder.org. If not, see <http://www.gnu.org/licenses/>.
18 from collections import Counter
20 from mygpo.db.couchdb.podcast_state import subscribed_users, \
21 subscribed_podcast_ids_by_user_id
24 def calc_similar_podcasts(podcast, num=20):
25 """
26 calculates and returns a list of podcasts that seem to be similar
27 to the given one.
29 Probably an expensive operation
30 """
32 users = subscribed_users(podcast)
34 podcasts = Counter()
36 for user_id in users:
37 user_subscriptions = subscribed_podcast_ids_by_user_id(user_id)
38 user_counter = Counter(user_subscriptions)
39 podcasts.update(user_counter)
41 return podcasts.most_common(num)