-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #72 from Virenbar/playlist
- Loading branch information
Showing
22 changed files
with
327 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { sortBy } from "lodash-es"; | ||
import { list } from "../data/stations.json"; | ||
|
||
export default function () { | ||
const sort = useSort(); | ||
const stations = computed(() => { | ||
switch (sort.value) { | ||
case "A-Z": | ||
return sortBy(list, S => S.title.toLowerCase()); | ||
case "new": | ||
return sortBy(list, S => S.prefix == "record" ? 0 : -S.id); | ||
default: | ||
return list; | ||
} | ||
}); | ||
|
||
return { | ||
stations | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
export default function () { | ||
function getHash() { | ||
return new URLSearchParams(location.hash.replace("#", "?")); | ||
} | ||
|
||
function getParameter<K extends keyof Parameters>(key: K) { | ||
const params = getHash(); | ||
const value = params.get(key); | ||
return value as Parameters[K] | null; | ||
} | ||
|
||
function setParameter<K extends keyof Parameters>(key: K, value: Parameters[K]) { | ||
const params = getHash(); | ||
params.set(key, value); | ||
location.hash = params.toString(); | ||
} | ||
|
||
return { | ||
getParameter, | ||
setParameter | ||
}; | ||
} | ||
|
||
interface Parameters { | ||
sort: Sort | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
export default function () { | ||
function getItem<K extends keyof Storage>(key: K): Storage[K] | null { | ||
const storage = window.localStorage; | ||
const value = storage.getItem(key); | ||
if (!value) { return null; } | ||
return JSON.parse(value) as Storage[K]; | ||
} | ||
|
||
function setItem<K extends keyof Storage>(key: K, value: Storage[K]) { | ||
const storage = window.localStorage; | ||
storage.setItem(key, JSON.stringify(value)); | ||
} | ||
|
||
return { | ||
getItem, | ||
setItem | ||
}; | ||
} | ||
|
||
interface Storage { | ||
stations: number[] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { saveAs } from "file-saver"; | ||
|
||
function getTrack(station: Station, quality: PlaylistQuality) { | ||
switch (quality) { | ||
case "AAC 64": | ||
return station.stream_64; | ||
case "AAC 96": | ||
return station.stream_128; | ||
default: | ||
return station.stream_64; | ||
} | ||
} | ||
|
||
function savePlaylist(quality: PlaylistQuality, checked: Set<number>) { | ||
const { stations } = useData(); | ||
const tracks = stations.value.filter(s => checked.has(s.id)); | ||
|
||
const name = `Radio Record (${quality})`; | ||
let playlist = "#EXTM3U\n"; | ||
playlist += `#PLAYLIST:${name}\n`; | ||
tracks.forEach(T => { | ||
playlist += `#EXTINF: -1,${T.title}\n`; | ||
playlist += `${getTrack(T, quality)}\n`; | ||
}); | ||
const blob = new Blob([playlist]); | ||
saveAs(blob, `${name}.m3u8`); | ||
console.log(`Playlist saved: ${name}(${tracks.length})`); | ||
|
||
} | ||
|
||
export default function () { | ||
return { | ||
savePlaylist | ||
}; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export const useSort = () => useState<string>("sort", () => ""); | ||
export const useSort = () => useState<Sort>("sort", () => "default"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<script setup lang="ts"> | ||
const { repository, branch } = useRuntimeConfig().public; | ||
</script> | ||
<template> | ||
<div class="container p-3 w-50"> | ||
<div class="card text-center"> | ||
<div class="card-header"> | ||
<b>О сайте</b> | ||
</div> | ||
<div class="card-body text-center w-75 mx-auto"> | ||
<p> | ||
Данный сайт использовался для изучения HTML/CSS/JS. | ||
</p> | ||
<p> | ||
Изначально был создан в виде самописного генератора страницы, затем был переписан на preact (альтернатива react). | ||
И в конечном итоге переписан на фреймворк Nuxt. | ||
</p> | ||
<p> | ||
Плейлисты с всегда актуальным списком каналов доступны | ||
<NuxtLink target="_blank" :to="`${repository}/tree/${branch}/playlists`"> | ||
<span>здесь</span> | ||
</NuxtLink>. | ||
</p> | ||
</div> | ||
<div class="card-footer text-center"> | ||
<NuxtLink class="btn btn-outline-primary" target="_blank" to="https://radiorecord.ru/"> | ||
Сайт радио Record | ||
</NuxtLink> | ||
</div> | ||
</div> | ||
</div> | ||
</template> |
Oops, something went wrong.