Skip to content

Commit

Permalink
Merge pull request #952 from openzim/remove_ted_multi
Browse files Browse the repository at this point in the history
Remove ability to create multiple ZIMs per TED recipe
  • Loading branch information
rgaudin authored Apr 18, 2024
2 parents 48b9276 + 670671f commit b400794
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 75 deletions.
81 changes: 7 additions & 74 deletions dispatcher/backend/src/common/schemas/offliners/ted.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from marshmallow import ValidationError, fields, validate, validates_schema
from marshmallow import fields, validate

from common.schemas import SerializableSchema, String, StringEnum
from common.schemas.fields import (
Expand All @@ -12,21 +12,11 @@ class TedFlagsSchema(SerializableSchema):
class Meta:
ordered = True

indiv_zims = fields.Boolean(
truthy=[True],
falsy=[False],
metadata={
"label": "Individual ZIM mode",
"description": "Whether to produce one ZIM per topic/playlist",
},
data_key="indiv-zims",
)

topics = String(
metadata={
"label": "Topics",
"description": (
"Comma-seperated list of topics to scrape; as given on ted.com/talks. "
"Comma-separated list of topics to scrape; as given on ted.com/talks. "
"Pass all for all topics"
),
},
Expand All @@ -36,7 +26,7 @@ class Meta:
metadata={
"label": "TED Playlists",
"description": (
"Comma-seperated list of TED playlist IDs to scrape. Pass all for all "
"Comma-separated list of TED playlist IDs to scrape. Pass all for all "
"playlists"
),
},
Expand All @@ -45,7 +35,8 @@ class Meta:
languages = String(
metadata={
"label": "Languages",
"description": "Comma-seperated list of languages to filter videos",
"description": "Comma-separated list of languages to filter videos. Do not "
"pass this parameter for all languages",
},
)

Expand All @@ -68,7 +59,7 @@ class Meta:
"description": (
"Language setting for subtitles. all: include all available subtitles, "
"matching (default): only subtitles matching language(s), none: include"
" no subtitle. Also accepts comma-seperated list of language(s)"
" no subtitle. Also accepts comma-separated list of language(s)"
),
},
)
Expand Down Expand Up @@ -112,18 +103,7 @@ class Meta:
),
"placeholder": "topic_eng",
},
)

name_format = String(
metadata={
"label": "Name Format",
"description": (
"Format for building individual --name argument. Use variable "
"{identity} for playlist id or topic name"
),
"placeholder": "{identity}_eng",
},
data_key="name-format",
required=True,
)

title = String(
Expand All @@ -133,14 +113,6 @@ class Meta:
}
)

title_format = String(
metadata={
"label": "Title Format",
"description": "Custom title format for individual ZIMs",
},
data_key="title-format",
)

description = String(
metadata={
"label": "Description",
Expand All @@ -151,14 +123,6 @@ class Meta:
validate=validate_zim_description,
)

description_format = String(
metadata={
"label": "Description Format",
"description": "Custom description format for individual ZIMs",
},
data_key="description-format",
)

creator = String(
metadata={
"label": "Content Creator",
Expand Down Expand Up @@ -228,17 +192,6 @@ class Meta:
data_key="tmp-dir",
)

metadata_from = String(
metadata={
"label": "Metadata JSON",
"description": (
"File path or URL to a JSON file holding custom metadata for individual"
" playlists/topics"
),
},
data_key="metadata-from",
)

zim_file = String(
metadata={
"label": "ZIM filename",
Expand All @@ -248,17 +201,6 @@ class Meta:
validate=validate_zim_filename,
)

zim_file_format = String(
metadata={
"label": "ZIM filename format",
"description": (
"Format for building individual --zim-file argument for individual "
"ZIMs. Uses --name-format otherwise"
),
},
data_key="zim-file-format",
)

debug = fields.Boolean(
truthy=[True],
falsy=[False],
Expand All @@ -280,12 +222,3 @@ class Meta:
},
data_key="locale",
)

@validates_schema
def validate(self, data, **kwargs):
if data.get("indiv_zims"):
if not data.get("name_format"):
raise ValidationError("name-format required in individual ZIMs mode")
else:
if not data.get("name"):
raise ValidationError("name required in normal mode")
2 changes: 1 addition & 1 deletion dispatcher/backend/src/utils/offliners.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
Offliner.ifixit: od("ifixit2zim", True, True),
Offliner.mwoffliner: od("mwoffliner", "outputDirectory", False),
Offliner.youtube: od("youtube2zim-playlists", True, False),
Offliner.ted: od("ted2zim-multi", True, False),
Offliner.ted: od("ted2zim", True, False),
Offliner.openedx: od("openedx2zim", True, False),
Offliner.nautilus: od("nautiluszim", True, False),
Offliner.zimit: od("zimit", True, "statsFilename"),
Expand Down

0 comments on commit b400794

Please sign in to comment.