Module:Screencap/doc
More actions
This is the documentation page for Module:Screencap
Overview
Module:Screencap is the Lua backend for Template:Screencap, the unified image tag for BattlestarWiki Media. It replaces the fragmented family of legacy sub-templates (
| The an unknown series, Season "Unknown" from an unknown episode. Please help us identify the episode by updating this tag or discussing it on the [[{{TALKPAGENAME}}|talk page]]. | |
| This capture is copyright by the copyright holder. Use of it here is believed to be fair use. | |
| The timestamp for this image is unknown. Please supply the time index for this capture. | |
| Screen capture (source unknown). Native resolution: unknown. | |
,
| The original Battlestar Galactica, Season "Unknown" from an unknown episode. Please help us identify the episode by updating this tag or discussing it on the [[{{TALKPAGENAME}}|talk page]]. | |
| This capture is copyright by Universal Studios. Use of it here is believed to be fair use. | |
| The timestamp for this image is unknown. Please supply the time index for this capture. | |
| Blu-ray screen capture. Native resolution: 1920×1080. | |
,
| File:BSG WIKI HDTV.png HD broadcast screen capture | |
|---|---|
| The Caprica, Season "Unknown" from an unknown episode. Please help us identify the episode by updating this tag or discussing it on the [[{{TALKPAGENAME}}|talk page]]. | |
| This capture is copyright by Universal Studios / Syfy. Use of it here is believed to be fair use. | |
| The timestamp for this image is unknown. Please supply the time index for this capture. | |
| HD broadcast screen capture. Native resolution: 1280×720 or 1920×1080. | |
, etc.) with a single module that auto-detects as much metadata as possible from the file itself, while allowing any detected value to be overridden via named template parameters.
The module does four things:
- Detects the series from filename prefix patterns
- Detects the season and episode from filename patterns (SxxExx, NxNN, or prose title hint)
- Detects the source type / quality tier from the file's pixel dimensions
- Renders a collapsible infobox and applies maintenance categories
Entry Point
The module exposes one public function:
| Function | Called by | Description |
|---|---|---|
p.main(frame) |
{{#invoke:Screencap|main}} in Template:Screencap |
Full pipeline: detect → render infobox → emit categories |
Series Detection
Series is detected by matching the start of the filename against a prefix table. Matching is case-sensitive on the prefix but tolerates spaces or underscores as separators (e.g. RDM -, RDM_).
| Filename starts with | Detected series key
|
|---|---|
RDM -, TRS -, BSG - S##, BSG - #x## |
rdm
|
CAP -, Caprica - |
cap
|
B&C -, BNC - |
bnc
|
TOS - |
tos
|
1980 -, G1980 - |
1980
|
| (no match) | unknown
|
Each series key maps to a SERIES_META entry containing the human-readable name, category abbreviation, wiki article links, and copyright holder used in the infobox.
To add a new series, add a new entry to both SERIES_PREFIXES and SERIES_META in the module.
Episode & Season Detection
The module attempts to extract season and episode numbers from the filename in this priority order:
| Pattern | Example filename | Result |
|---|---|---|
SxxExx (standard) |
RDM - S04E20 - Daybreak.jpg |
Season 4, Episode 20 |
NxNN (alternate) |
BSG - 1x05 - Act of Contrition.jpg |
Season 1, Episode 5 |
| Prose title hint | TOS - The Lost Warrior - Apollo.jpg |
Title hint: "The Lost Warrior - Apollo" |
| (no match) | Adamabed.jpg |
No season, no episode, no hint |
When only a title hint is extracted (no season/episode numbers), the infobox displays the hint with a message asking editors to verify and supply the full episode name. When nothing is extracted at all, the infobox flags the image as unidentified and links to the talk page.
Note: the |episode= parameter is not auto-detected from the filename — it must be explicitly supplied if you want a linked episode name in the infobox. The filename extraction only produces season/episode numbers or a hint string.
Source Type Detection
When no |type= override is supplied, the module reads the file's pixel dimensions via mw.title.getCurrentTitle().file and classifies the source using the longest pixel axis (so portrait-orientation promotional photographs are handled correctly alongside landscape screencaps).
| Longest pixel dimension | Detected type |
Label shown |
|---|---|---|
| ≥ 3840 px | 4k |
4K Ultra HD screen capture |
| ≥ 1920 px | bluray |
Blu-ray screen capture |
| ≥ 1280 px | hdtv |
HD broadcast screen capture |
| ≥ 853 px | ntscdvd |
NTSC DVD screen capture |
| ≥ 720 px | paldvd |
PAL DVD screen capture |
| < 720 px | dvd |
DVD screen capture |
| dimensions unavailable | unknown |
screen capture (source unknown) |
Dimensions are unavailable when the module runs outside a File: page context (e.g. during template sandbox testing), in which case it falls back gracefully to unknown rather than erroring.
All valid type keys that can be used as overrides:
| Key | Description |
|---|---|
4k |
4K UHD Blu-ray (≥ 3840px) |
bluray |
Blu-ray / 1080p stream |
hdtv |
HD broadcast or download |
hddvd |
HD DVD (manual override only — not auto-detected) |
itunes |
iTunes / digital download (manual override only) |
ntscdvd |
NTSC DVD |
ntscb |
NTSC broadcast (manual override only) |
paldvd |
PAL DVD |
palb |
PAL broadcast (manual override only) |
promo |
Promotional photograph (manual override only) |
dvd |
Generic / low-res DVD |
unknown |
Source unknown |
hddvd, itunes, ntscb, palb, and promo cannot be auto-detected from dimensions alone and must always be set via |type=.
Timestamp Handling
The |timestamp= parameter accepts three input formats:
| Input | Interpretation | Displayed as |
|---|---|---|
427 |
Bare integer → total seconds | 00:07:07
|
3662 |
Bare integer → total seconds | 01:01:02
|
00:07:07 |
Already HH:MM:SS | 00:07:07
|
0h20m42s |
Non-numeric string → passed through | 0h20m42s
|
Any input that does not parse as a pure number via tonumber() is passed through as-is, so existing timestamps in any format continue to work without changes.
Infobox Output
The rendered infobox is a standard MediaWiki wikitable with class wikitable mw-collapsible screencap-infobox. Rows are emitted in this order:
- Header — source type icon + label (collapsible toggle)
- Series / episode identification line with language bar links
- Copyright notice (links to Wikipedia)
- Timestamp (or missing-timestamp notice)
- Source description and native resolution
- Detected pixel dimensions (if available)
- Scaling note (if
|scaled=yes) - Cropping note (if
|cropped=yes) - Aspect ratio confirmation (if
|aspect=yes)
Cross-wiki icon rendering
Source type icons are referenced using standard [[File:Name|30px|link=]] wikitext. The language wikis (de., fr., etc.) serve these files via ForeignAPIRepo from media.battlestarwiki.org, so the icons render correctly everywhere without any special URL construction.
Category Output
Categories are appended after the infobox and applied automatically — no manual [[Category:...]] tags are needed on file pages.
For a Blu-ray RDM image of "Daybreak" from Season 4, the following categories would be applied:
[[Category:Screen captures]][[Category:Screen captures (TRS)]][[Category:Blu-ray screen captures (TRS)]][[Category:Screen captures by season 4 (TRS)]][[Category:Screen captures (Daybreak)]][[Category:Blu-ray screen captures (Daybreak)]]
Additional maintenance categories are applied automatically based on conditions:
| Condition | Maintenance category added |
|---|---|
type is unknown |
Screen captures requiring source identification
|
type is ntscdvd, paldvd, ntscb, or palb |
Screen captures requiring upgrade
|
Extending the Module
Adding a new series
Add one or more entries to SERIES_PREFIXES (for filename detection) and a corresponding entry to SERIES_META (for display metadata):
<syntaxhighlight lang="lua"> -- In SERIES_PREFIXES: { pattern = "^BLOOD%s*[-_]%s*", series = "bnc" },
-- In SERIES_META: bnc = {
name = "Battlestar Galactica: Blood & Chrome", abbr = "BNC", enlink = "Battlestar Galactica: Blood & Chrome", copyright = "Universal Studios / Syfy",
}, </syntaxhighlight>
Adding a new source type
Add an entry to TYPE_LABELS and a corresponding entry to the iconMap inside renderInfobox:
<syntaxhighlight lang="lua"> -- In TYPE_LABELS: webdl = { short = "Web DL", long = "web download screen capture", badge = "Web DL", res = "variable" },
-- In iconMap inside renderInfobox: webdl = "File:BSG WIKI WebDL.png", </syntaxhighlight>
See Also
- Template:Screencap — the template that invokes this module
- Template:Screencap/doc — end-user documentation and parameter reference
- Template:Master screencap — legacy parent template (now a wrapper)
- Battlestar Wiki Media:Image tagging policy