filter streams with no HLS link

This commit is contained in:
2024-02-23 11:11:03 +00:00
parent 3641cadd0d
commit 364d2c272f
7 changed files with 33 additions and 40 deletions

View File

@ -52,8 +52,6 @@
"scripts": { "scripts": {
"start": "vite", "start": "vite",
"build": "vite build", "build": "vite build",
"deploy": "__XXX='false' && yarn build && npx wrangler pages publish --project-name nostr-live build",
"deploy:xxzap": "__XXX='true' && yarn build && npx wrangler pages publish --project-name xxzap build",
"intl-extract": "formatjs extract 'src/**/*.ts*' --ignore='**/*.d.ts' --out-file src/lang.json --flatten true", "intl-extract": "formatjs extract 'src/**/*.ts*' --ignore='**/*.d.ts' --out-file src/lang.json --flatten true",
"intl-compile": "formatjs compile src/lang.json --out-file src/translations/en.json" "intl-compile": "formatjs compile src/lang.json --out-file src/translations/en.json"
}, },

View File

@ -2,8 +2,6 @@
/// <reference types="@webbtc/webln-types" /> /// <reference types="@webbtc/webln-types" />
/// <reference types="vite/client" /> /// <reference types="vite/client" />
declare const __XXX: boolean;
declare const __XXX_HOST: string;
declare const __ZAP_STREAM_VERSION__: string; declare const __ZAP_STREAM_VERSION__: string;
declare module "*.md" { declare module "*.md" {

View File

@ -10,7 +10,7 @@ import { Icon } from "./icon";
import { useStreamProvider } from "@/hooks/stream-provider"; import { useStreamProvider } from "@/hooks/stream-provider";
import { NostrStreamProvider, StreamProvider, StreamProviders } from "@/providers"; import { NostrStreamProvider, StreamProvider, StreamProviders } from "@/providers";
import { StreamEditor, StreamEditorProps } from "./stream-editor"; import { StreamEditor, StreamEditorProps } from "./stream-editor";
import { eventLink, findTag } from "@/utils"; import { eventLink } from "@/utils";
import { NostrProviderDialog } from "./nostr-provider-dialog"; import { NostrProviderDialog } from "./nostr-provider-dialog";
import AsyncButton from "./async-button"; import AsyncButton from "./async-button";
@ -38,14 +38,10 @@ function NewStream({ ev, onFinish }: Omit<StreamEditorProps, "onFinish"> & { onF
onFinish={ex => { onFinish={ex => {
currentProvider.updateStreamInfo(system, ex); currentProvider.updateStreamInfo(system, ex);
if (!ev) { if (!ev) {
if (findTag(ex, "content-warning") && __XXX_HOST && __XXX === false) {
location.href = `${__XXX_HOST}/${eventLink(ex)}`;
} else {
navigate(`/${eventLink(ex)}`, { navigate(`/${eventLink(ex)}`, {
state: ex, state: ex,
}); });
onFinish?.(); onFinish?.();
}
} else { } else {
onFinish?.(); onFinish?.();
} }

View File

@ -75,7 +75,8 @@ export function NostrProviderDialog({
const raw = Math.max(0, info.balance / ep.rate); const raw = Math.max(0, info.balance / ep.rate);
if (ep.unit === "min" && raw > 60) { if (ep.unit === "min" && raw > 60) {
const pm = hrs * 60 * ep.rate; const pm = hrs * 60 * ep.rate;
return <> return (
<>
{`${(raw / 60).toFixed(0)} hour @ ${ep.rate} sats/${ep.unit}`} {`${(raw / 60).toFixed(0)} hour @ ${ep.rate} sats/${ep.unit}`}
&nbsp; or <br /> &nbsp; or <br />
{`${pm.toLocaleString()} sats/month ($${(rate.ask * pm * 1e-8).toFixed(2)}/mo) streaming ${hrs} hrs/month`} {`${pm.toLocaleString()} sats/month ($${(rate.ask * pm * 1e-8).toFixed(2)}/mo) streaming ${hrs} hrs/month`}
@ -84,6 +85,7 @@ export function NostrProviderDialog({
<input type="number" value={hrs} onChange={e => setHrs(e.target.valueAsNumber)} /> <input type="number" value={hrs} onChange={e => setHrs(e.target.valueAsNumber)} />
</div> </div>
</> </>
);
} }
return `${raw.toFixed(0)} ${ep.unit} @ ${ep.rate} sats/${ep.unit}`; return `${raw.toFixed(0)} ${ep.unit} @ ${ep.rate} sats/${ep.unit}`;
} }

View File

@ -56,24 +56,25 @@ export function useStreamsFeed(tag?: string) {
const feed = useRequestBuilder(rb); const feed = useRequestBuilder(rb);
const feedSorted = useMemo(() => { const feedSorted = useMemo(() => {
if (feed) { if (feed) {
if (__XXX) {
return [...feed].filter( return [...feed].filter(
a => a => !import.meta.env.VITE_SINGLE_PUBLISHER || import.meta.env.VITE_SINGLE_PUBLISHER === getHost(a)
findTag(a, "content-warning") !== undefined &&
(!import.meta.env.VITE_SINGLE_PUBLISHER || import.meta.env.VITE_SINGLE_PUBLISHER === getHost(a))
); );
} else {
return [...feed].filter(
a =>
findTag(a, "content-warning") === undefined &&
(!import.meta.env.VITE_SINGLE_PUBLISHER || import.meta.env.VITE_SINGLE_PUBLISHER === getHost(a))
);
}
} }
return []; return [];
}, [feed]); }, [feed]);
const live = feedSorted.filter(a => findTag(a, "status") === StreamState.Live).sort(sortStarts); const live = feedSorted
.filter(a => {
try {
return (
findTag(a, "status") === StreamState.Live &&
a.tags.some(a => a[0] === "streaming" && new URL(a[1]).pathname.includes(".m3u8"))
);
} catch {
return false;
}
})
.sort(sortStarts);
const planned = feedSorted.filter(a => findTag(a, "status") === StreamState.Planned).sort(sortStarts); const planned = feedSorted.filter(a => findTag(a, "status") === StreamState.Planned).sort(sortStarts);
const ended = feedSorted const ended = feedSorted
.filter(a => { .filter(a => {

View File

@ -162,7 +162,7 @@ export function StreamPage({ link, evPreload }: { evPreload?: NostrEvent; link:
status={status} status={status}
/> />
</Suspense> </Suspense>
<ProfileInfo ev={ev} goal={goal} /> <ProfileInfo ev={ev as TaggedNostrEvent} goal={goal} />
<StreamCards host={host} /> <StreamCards host={host} />
</div> </div>
<LiveChat <LiveChat

View File

@ -41,7 +41,5 @@ export default defineConfig({
}, },
define: { define: {
global: {}, global: {},
__XXX: process.env["__XXX"] || JSON.stringify(false),
__XXX_HOST: JSON.stringify("https://xxzap.com"),
}, },
}); });