Skip to content

Commit

Permalink
youtube: mark videos that were deleted
Browse files Browse the repository at this point in the history
  • Loading branch information
karlicoss committed Jun 5, 2020
1 parent 2223d01 commit 7eb1797
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions modules/youtube.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,26 @@
from orger.inorganic import node, link
from orger.common import dt_heading

from my.media.youtube import get_watched
from my.media.youtube import watched

from itertools import groupby


class YoutubeView(Mirror):
def get_items(self) -> Mirror.Results:
watched = get_watched()
by_url = lambda w: w.url
by_when = lambda w: w.when
items = [
max(group, key=by_when)
for _, group in groupby(sorted(watched, key=by_url), key=by_url)
for _, group in groupby(sorted(watched(), key=by_url), key=by_url)
]
items = sorted(items, key=by_when)
# TODO for each url only take latest?
for item in items:
deleted = item.url == item.title # todo move to HPI?
l = link(title=item.title + (' (DELETED)' if deleted else ''), url=item.url)
yield (item.url, node(
heading=dt_heading(item.when, link(title=item.title, url=item.url)),
heading=dt_heading(item.when, l),
))


Expand Down

0 comments on commit 7eb1797

Please sign in to comment.