Skip to content

Commit

Permalink
Merge pull request #148 from booxter/lcli-no-dup-urls
Browse files Browse the repository at this point in the history
Lcli no dup urls
  • Loading branch information
booxter authored Nov 22, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
2 parents 5dc3975 + ff01b7b commit 48ba885
Showing 2 changed files with 18 additions and 6 deletions.
22 changes: 18 additions & 4 deletions src/letsrolld/webcli/cli.py
Original file line number Diff line number Diff line change
@@ -14,9 +14,6 @@
from letsrolld_api_client.api.default import get_reports_id


DEFAULT_OFFERS = set(lfilm.STREAM_SERVICES)


# TODO: make the url configurable
client = Client(base_url="http://localhost:8000")

@@ -36,9 +33,26 @@ def list_director(director):
return template.render(director=director)


def _get_offers_with_unique_urls(film):
offers_to_report = []
urls_seen = set()
for service in lfilm.STREAM_SERVICES:
for o in film.offers:
if o.name != service:
continue
if o.url not in urls_seen:
offers_to_report.append(o.name)
urls_seen.add(o.url)
return offers_to_report


def _get_services_to_report(film):
return _get_offers_with_unique_urls(film)


def report_film(film):
template = env.get_template("film-full.j2")
return template.render(film=film, offers=DEFAULT_OFFERS)
return template.render(film=film, offers=_get_services_to_report(film))


def list_report(report):
2 changes: 0 additions & 2 deletions src/letsrolld/webcli/templates/film-full.j2
Original file line number Diff line number Diff line change
@@ -17,7 +17,5 @@
{% for offer in film.offers|selectattr("name", "in", offers) -%}
{%- if offer.url -%}
{{ offer.name }}: {{ offer.url }}
{% else -%}
{{ offer.name }}
{% endif -%}
{% endfor -%}

0 comments on commit 48ba885

Please sign in to comment.