apple like to be snowflake.

This commit is contained in:
ArabCoders 2025-02-28 01:21:45 +03:00
parent e847fea2dd
commit f0836ddd77
3 changed files with 18 additions and 13 deletions

1
.vscode/launch.json vendored
View file

@ -10,7 +10,6 @@
"runtimeArgs": [ "runtimeArgs": [
"run", "run",
"dev", "dev",
"--",
"--port", "--port",
"8082" "8082"
], ],

View file

@ -576,12 +576,7 @@ def get_mime_type(metadata: dict, file_path: pathlib.Path) -> str:
"matroska": "video/x-matroska", # Default for MKV "matroska": "video/x-matroska", # Default for MKV
"webm": "video/webm", # MKV can also be WebM "webm": "video/webm", # MKV can also be WebM
"mp4": "video/mp4", "mp4": "video/mp4",
"mov": "video/quicktime",
"avi": "video/x-msvideo",
"flv": "video/x-flv",
"ogg": "video/ogg",
"mpegts": "video/mp2t", "mpegts": "video/mp2t",
"3gp": "video/3gpp",
} }
# Check format_name against known formats # Check format_name against known formats

View file

@ -28,7 +28,7 @@
</template> </template>
<script setup> <script setup>
import { onMounted, onUpdated, ref, defineProps, defineEmits, onUnmounted } from 'vue' import { onMounted, onUpdated, ref, onUnmounted } from 'vue'
import Hls from 'hls.js' import Hls from 'hls.js'
import Plyr from 'plyr' import Plyr from 'plyr'
import 'plyr/dist/plyr.css' import 'plyr/dist/plyr.css'
@ -52,7 +52,6 @@ const thumbnail = ref('')
const artist = ref('') const artist = ref('')
const title = ref('') const title = ref('')
const isAudio = ref(false) const isAudio = ref(false)
const isApple = /(iPhone|iPod|iPad).*AppleWebKit/i.test(navigator.userAgent)
let player = null; let player = null;
let hls = null; let hls = null;
@ -64,17 +63,29 @@ const eventFunc = e => {
} }
onMounted(async () => { onMounted(async () => {
const isApple = /(iPhone|iPod|iPad).*AppleWebKit/i.test(navigator.userAgent)
const response = await (await request(makeDownload(config, props.item, 'api/file/info'))).json() const response = await (await request(makeDownload(config, props.item, 'api/file/info'))).json()
if (props.item.extras?.thumbnail) { if (props.item.extras?.thumbnail) {
thumbnail.value = '/api/thumbnail?url=' + encodePath(props.item.extras.thumbnail) thumbnail.value = '/api/thumbnail?url=' + encodePath(props.item.extras.thumbnail)
} }
sources.value.push({ // -- check if mimetype is video/mp4 and device is apple
src: makeDownload(config, props.item, isApple ? 'm3u8' : 'api/download'), // -- as always apple, apple like to be snowflakes.
type: isApple ? response.mimetype : 'application/x-mpegURL', if (isApple) {
onerror: e => src_error(e), const allowedCodec = response.mimetype && response.mimetype.includes('video/mp4')
}) sources.value.push({
src: makeDownload(config, props.item, allowedCodec ? 'api/download' : 'm3u8'),
type: allowedCodec ? response.mimetype : 'application/x-mpegURL',
onerror: e => src_error(e),
})
} else {
sources.value.push({
src: makeDownload(config, props.item, 'api/download'),
type: response.mimetype,
onerror: e => src_error(e),
})
}
if (props.item.extras?.channel) { if (props.item.extras?.channel) {
artist.value = props.item.extras.channel artist.value = props.item.extras.channel