improved video.html added fix time duration fro livestreams
This commit is contained in:
parent
7c9aa30f10
commit
d6edd14f16
5 changed files with 105 additions and 27 deletions
28
templates/A.html
Normal file
28
templates/A.html
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
{% extends "results_layout.html" %}
|
||||||
|
|
||||||
|
{% block body %}
|
||||||
|
<p class="fetched fetched_dif fetched_vid">{{ lang_data.results.results }} {{ fetched }} {{ lang_data.results.seconds }}</p>
|
||||||
|
{% if results %}
|
||||||
|
{% for result in results %}
|
||||||
|
<div><div class="video__results">
|
||||||
|
<div class="video__img__results">
|
||||||
|
<a href="{{ result[0] }}"> <img src="{{ result[6] }}">
|
||||||
|
<div class="duration">{{ result[7] }}</div>
|
||||||
|
</img></a>
|
||||||
|
</div>
|
||||||
|
<div class="results video-results-margin">
|
||||||
|
<a {% if settings.new_tab == "active" %} target="_blank" {% endif %} href="{{ result[0] }}"><h3 class="video_title" href="{{ result[0] }}">{{ result[1] }}</h3></a>
|
||||||
|
<p class="stats">{{ result[3] }} • {{ result[2] }}</p>
|
||||||
|
<p class="publish__info">{{ result[5] }} <span class="pipe">|</span> {{ result[4] }}</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
{% else %}
|
||||||
|
<div class="no-results-found">
|
||||||
|
Your search '{{ q }}' came back with no results.<br>
|
||||||
|
Try rephrasing your search term and/or recorrect any spelling mistakes.
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
{% endblock %}
|
|
@ -52,6 +52,7 @@
|
||||||
<button class="results-save" type="submit">Apply settings</button>
|
<button class="results-save" type="submit">Apply settings</button>
|
||||||
</form>
|
</form>
|
||||||
<div class="search-results">
|
<div class="search-results">
|
||||||
|
<!-- Results go here -->
|
||||||
{{ if .Results }}
|
{{ if .Results }}
|
||||||
<div class="images images_viewer_hidden">
|
<div class="images images_viewer_hidden">
|
||||||
<!-- Image Viewer Placeholder - Adapt as necessary -->
|
<!-- Image Viewer Placeholder - Adapt as necessary -->
|
||||||
|
|
|
@ -53,6 +53,7 @@
|
||||||
</form>
|
</form>
|
||||||
<div class="results">
|
<div class="results">
|
||||||
<!-- Results go here -->
|
<!-- Results go here -->
|
||||||
|
{{if .Results}}
|
||||||
{{range .Results}}
|
{{range .Results}}
|
||||||
<div class="result_item">
|
<div class="result_item">
|
||||||
<a href="{{.URL}}">{{.URL}}</a>
|
<a href="{{.URL}}">{{.URL}}</a>
|
||||||
|
@ -61,7 +62,9 @@
|
||||||
</div>
|
</div>
|
||||||
<br>
|
<br>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
{{else}}
|
||||||
|
<div class="no-results">No results found for '{{ .Query }}'. Try different keywords.</div>
|
||||||
|
{{end}}
|
||||||
</div>
|
</div>
|
||||||
<!-- Additional features and formatting based on inspiration.html -->
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -3,27 +3,62 @@
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>Video Results</title>
|
<title>{{.Query}} - Ocásek</title>
|
||||||
<link rel="stylesheet" href="/static/css/style.css">
|
<link rel="stylesheet" href="/static/css/style.css">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="content">
|
<form action="/search" id="prev-next-form" class="results-search-container" method="GET" autocomplete="off">
|
||||||
<h1>Video Results</h1>
|
<h1 class="logomobile"><a class="no-decoration" href="./">Ocásek</a></h1>
|
||||||
|
<div class="wrapper-results">
|
||||||
|
<input type="text" name="q" value="{{ .Query }}" id="search-input" placeholder="Type to search..." />
|
||||||
|
<button id="search-wrapper-ico" class="material-icons-round" name="t" value="video">search</button>
|
||||||
|
<input type="submit" class="hide" name="t" value="video" />
|
||||||
|
</div>
|
||||||
|
<div class="sub-search-button-wrapper">
|
||||||
|
<div class="search-container-results-btn">
|
||||||
|
<button id="sub-search-wrapper-ico" class="material-icons-round clickable" name="t" value="text">search</button>
|
||||||
|
<button name="t" value="text" class="clickable">Web</button>
|
||||||
|
</div>
|
||||||
|
<div class="search-container-results-btn">
|
||||||
|
<button id="sub-search-wrapper-ico" class="material-icons-round clickable" name="t" value="image">image</button>
|
||||||
|
<button name="t" value="image" class="clickable">Images</button>
|
||||||
|
</div>
|
||||||
|
<div class="search-container-results-btn">
|
||||||
|
<button id="sub-search-wrapper-ico" class="material-icons-round clickable search-active" name="t" value="video">movie</button>
|
||||||
|
<button name="t" value="video" class="clickable search-active">Videos</button>
|
||||||
|
</div>
|
||||||
|
<div class="search-container-results-btn">
|
||||||
|
<button id="sub-search-wrapper-ico" class="material-icons-round clickable" name="t" value="reddit">forum</button>
|
||||||
|
<button name="t" value="forum" class="clickable">Forums</button>
|
||||||
|
</div>
|
||||||
|
<div class="search-container-results-btn">
|
||||||
|
<button id="sub-search-wrapper-ico" class="material-icons-round clickable" name="t" value="torrent">share</button>
|
||||||
|
<button name="t" value="torrent" class="clickable">Torrents</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
<!-- Results go here -->
|
||||||
|
<p class="fetched fetched_dif fetched_vid"><!-- { fetched } --></p>
|
||||||
{{ if .Results }}
|
{{ if .Results }}
|
||||||
{{ range .Results }}
|
{{ range .Results }}
|
||||||
<div class="video-result">
|
<div>
|
||||||
<h2>{{ .Title }}</h2>
|
<div class="video__results">
|
||||||
<a href="{{ .Href }}" target="_blank">
|
<div class="video__img__results">
|
||||||
<img src="{{ .Image }}" alt="{{ .Title }}" style="width:100%;max-width:600px;">
|
<a href="{{ .Href }}"> <img src="{{ .Image }}">
|
||||||
</a>
|
<div class="duration">{{ .Duration }}</div>
|
||||||
<p>{{ .Views }} views | {{ .Duration }}</p>
|
</img></a>
|
||||||
<p>By {{ .Creator }}</p>
|
</div>
|
||||||
|
<div class="results video-results-margin">
|
||||||
|
<h3 class="video_title" href="{{ .Href }}">{{ .Title }}</h3></a>
|
||||||
|
<p class="stats">{{ .Views }} <span class="pipe">|</span> {{ .Date }}</p>
|
||||||
|
<p class="publish__info">YouTube <span class="pipe">|</span> {{ .Creator }}</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- Removed the break as it's not directly supported in Go templates. If you want only the first result, adjust in Go code instead -->
|
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ else }}
|
{{ else }}
|
||||||
<p>No results found. Try adjusting your search term.</p>
|
<div class="no-results">No results found for '{{ .Query }}'. Try different keywords.</div>>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
</div>
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
13
video.go
13
video.go
|
@ -45,9 +45,11 @@ func formatViews(views int) string {
|
||||||
case views >= 1_000_000_000:
|
case views >= 1_000_000_000:
|
||||||
return fmt.Sprintf("%.1fB views", float64(views)/1_000_000_000)
|
return fmt.Sprintf("%.1fB views", float64(views)/1_000_000_000)
|
||||||
case views >= 1_000_000:
|
case views >= 1_000_000:
|
||||||
return fmt.Sprintf("%dM views", views/1_000_000)
|
return fmt.Sprintf("%.1fM views", float64(views)/1_000_000)
|
||||||
case views >= 10_000:
|
case views >= 10_000:
|
||||||
return fmt.Sprintf("%.1fK views", float64(views)/1_000)
|
return fmt.Sprintf("%.1fK views", float64(views)/1_000)
|
||||||
|
case views == 1:
|
||||||
|
return fmt.Sprintf("%d view", views)
|
||||||
default:
|
default:
|
||||||
return fmt.Sprintf("%d views", views)
|
return fmt.Sprintf("%d views", views)
|
||||||
}
|
}
|
||||||
|
@ -55,9 +57,14 @@ func formatViews(views int) string {
|
||||||
|
|
||||||
// formatDuration formats video duration as done in the Python code
|
// formatDuration formats video duration as done in the Python code
|
||||||
func formatDuration(seconds int) string {
|
func formatDuration(seconds int) string {
|
||||||
|
if 0 > seconds {
|
||||||
|
return "Live"
|
||||||
|
}
|
||||||
|
|
||||||
hours := seconds / 3600
|
hours := seconds / 3600
|
||||||
minutes := (seconds % 3600) / 60
|
minutes := (seconds % 3600) / 60
|
||||||
seconds = seconds % 60
|
seconds = seconds % 60
|
||||||
|
|
||||||
if hours > 0 {
|
if hours > 0 {
|
||||||
return fmt.Sprintf("%02d:%02d:%02d", hours, minutes, seconds)
|
return fmt.Sprintf("%02d:%02d:%02d", hours, minutes, seconds)
|
||||||
}
|
}
|
||||||
|
@ -115,6 +122,10 @@ func handleVideoSearch(w http.ResponseWriter, query, safe, lang string, page int
|
||||||
if item.Type == "channel" || item.Type == "playlist" {
|
if item.Type == "channel" || item.Type == "playlist" {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
if item.UploadedDate == "" {
|
||||||
|
item.UploadedDate = "Now"
|
||||||
|
}
|
||||||
|
|
||||||
results = append(results, VideoResult{
|
results = append(results, VideoResult{
|
||||||
Href: fmt.Sprintf("https://youtube.com%s", item.URL),
|
Href: fmt.Sprintf("https://youtube.com%s", item.URL),
|
||||||
Title: item.Title,
|
Title: item.Title,
|
||||||
|
|
Loading…
Add table
Reference in a new issue