export const VIDEO_DETAIL_BASE_URL = 'https://admin.piaoquantv.com/cms/post-detail'

export interface VideoUrlFields {
  url1?: string | null
  url2?: string | null
  video_detail_url?: string | null
}

/** 解构结果链接：优先 url2，为空则用 url1。 */
export function pickDecodeUrl(video: VideoUrlFields): string | null {
  const url2 = video.url2?.trim()
  if (url2) return url2
  const url1 = video.url1?.trim()
  return url1 || null
}

export function videoDetailUrl(vid: string, fallbackUrl?: string | null): string {
  const custom = fallbackUrl?.trim()
  if (custom) return custom
  return `${VIDEO_DETAIL_BASE_URL}/${vid}/detail`
}
