Skip to content

Commit

Permalink
Merge branch 'main' into fix_usdb_covers_fallback
Browse files Browse the repository at this point in the history
  • Loading branch information
bohning committed Feb 2, 2025
2 parents 8699379 + ec64df8 commit ae43be3
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 52 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
<!-- 0.11.0 -->

# Changes
- Add more fine-grained options for video container/codec selection.

## Fixes

## Features

<!-- 0.10.0 -->

# Changes
Expand Down
77 changes: 39 additions & 38 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion src/usdb_syncer/gui/forms/SettingsDialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@
<item row="0" column="0">
<widget class="QLabel" name="label_video_container">
<property name="text">
<string>Container:</string>
<string>Container/codec:</string>
</property>
</widget>
</item>
Expand All @@ -501,6 +501,9 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;For &lt;span style=&quot; font-weight:700;&quot;&gt;UltraStar deluxe&lt;/span&gt;, &lt;span style=&quot; font-weight:700;&quot;&gt;Performous&lt;/span&gt;, &lt;span style=&quot; font-weight:700;&quot;&gt;Vocaluxe&lt;/span&gt; or other ffmpeg-based karaoke softwares, choose &amp;quot;Best available container/codec&amp;quot; or &amp;quot;mp4 (best available codec)&amp;quot; if you prefer to have an mp4 container.&lt;/p&gt;&lt;p&gt;For &lt;span style=&quot; font-weight:700;&quot;&gt;UltraStar CMD&lt;/span&gt; (Windows), &lt;span style=&quot; font-weight:700;&quot;&gt;Melody Mania&lt;/span&gt; (Windows) and low-power computers, choose &amp;quot;mp4 (AVC/H.264).&lt;/p&gt;&lt;p&gt;Otherwise, select a container/codec option that your software supports.&lt;/p&gt;&lt;p&gt;If the selected container/format option is not available for a given song, the syncer will try to at least get the requested container, and if that is not available either, it will fallback to the best available container/codec.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item row="2" column="0">
Expand Down
34 changes: 22 additions & 12 deletions src/usdb_syncer/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,32 +381,42 @@ def cookies(self) -> CookieJar | None:
class VideoContainer(Enum):
"""Video containers that can be requested when downloading with ytdl."""

BEST = "bestvideo"
MP4 = "mp4"
MP4_NO_VP9 = "mp4_no_vp9"
MP4_AV1 = "mp4_av1"
MP4_AVC = "mp4_avc"
MP4_VP9 = "mp4_vp9"
WEBM = "webm"
BEST = "bestvideo"

def __str__(self) -> str:
match self:
case VideoContainer.BEST:
return "Best available container/codec"
case VideoContainer.MP4:
return ".mp4 (any codec)"
case VideoContainer.MP4_NO_VP9:
return ".mp4 (no VP9)"
return ".mp4 (best available codec)"
case VideoContainer.MP4_AV1:
return ".mp4 (AV1 codec)"
case VideoContainer.MP4_AVC:
return ".mp4 (AVC/H.264 codec)"
case VideoContainer.MP4_VP9:
return ".mp4 (VP9 codec)"
case VideoContainer.WEBM:
return ".webm (VP9)"
case VideoContainer.BEST:
return "Best available"
return ".webm (VP9 codec)"
case _ as unreachable:
assert_never(unreachable)

def ytdl_format(self) -> str:
match self:
case VideoContainer.MP4 | VideoContainer.WEBM:
return f"bestvideo*[ext={self.value}]"
case VideoContainer.MP4_NO_VP9:
return "bestvideo*[ext=mp4][vcodec!~='vp0?9']"
case VideoContainer.BEST:
return "bestvideo*"
case VideoContainer.MP4 | VideoContainer.WEBM:
return f"bestvideo*[ext={self.value}]/bestvideo*"
case VideoContainer.MP4_AV1:
return "bestvideo*[ext=mp4][vcodec~='^av01']/bestvideo*[ext=mp4]/bestvideo*"
case VideoContainer.MP4_AVC:
return "bestvideo*[ext=mp4][vcodec~='^(avc|h264)']/bestvideo*[ext=mp4]/bestvideo*"
case VideoContainer.MP4_VP9:
return "bestvideo*[ext=mp4][vcodec~='^vp0?9']/bestvideo*[ext=mp4]/bestvideo*"
case _ as unreachable:
assert_never(unreachable)

Expand Down
7 changes: 6 additions & 1 deletion src/usdb_syncer/song_txt/headers.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ def _set_header_value(kwargs: dict[str, Any], header: str, value: str) -> None:
header = "creator" if header == "AUTHOR" else header.lower()
if header in (
"artist",
"version",
"language",
"edition",
"genre",
Expand All @@ -193,12 +194,16 @@ def _set_header_value(kwargs: dict[str, Any], header: str, value: str) -> None:
"creator",
"mp3",
"audio",
"audiourl",
"vocals",
"instrumental",
"cover",
"coverurl",
"background",
"relative",
"backgroundurl",
"video",
"videourl",
"relative",
"p1",
"p2",
"encoding",
Expand Down

0 comments on commit ae43be3

Please sign in to comment.