mirror of
https://github.com/ThatGuySam/doesitarm.git
synced 2026-05-15 06:35:20 -07:00
Fix video routes generating error
This commit is contained in:
parent
5bf72f1d0a
commit
fa222d3116
5 changed files with 49 additions and 6 deletions
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
<div class="video-card">
|
||||
<a
|
||||
:href="video.endpoint"
|
||||
:href="videoEndpoint"
|
||||
class=""
|
||||
>
|
||||
<div class="video-card-container relative overflow-hidden bg-black">
|
||||
|
|
@ -47,6 +47,8 @@
|
|||
|
||||
<script>
|
||||
|
||||
import { getVideoEndpoint } from '~/helpers/app-derived.js'
|
||||
|
||||
export default {
|
||||
props: {
|
||||
video: {
|
||||
|
|
@ -74,7 +76,13 @@ export default {
|
|||
// console.log('thumbnail', thumbnail)
|
||||
return `${thumbnail.url} ${thumbnail.width}w`
|
||||
}).join(', ')
|
||||
},
|
||||
videoEndpoint () {
|
||||
return getVideoEndpoint(this.video)
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
getVideoEndpoint
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,9 +3,20 @@
|
|||
export function getAppEndpoint ( app ) {
|
||||
// console.log('app', app)
|
||||
|
||||
if(app.category !== Object(app.category)) {
|
||||
console.warn('app has no categories', app)
|
||||
}
|
||||
|
||||
if (app.category.slug === 'homebrew') return `/formula/${app.slug}`
|
||||
|
||||
if (app.category.slug === 'games') return `/game/${app.slug}`
|
||||
|
||||
return `/app/${app.slug}`
|
||||
}
|
||||
|
||||
export function getVideoEndpoint ( video ) {
|
||||
|
||||
return `/tv/${video.slug}`
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import slugify from 'slugify'
|
|||
import axios from 'axios'
|
||||
|
||||
import { byTimeThenNull } from './sort-list.js'
|
||||
import { getVideoEndpoint } from './app-derived.js'
|
||||
import parseGithubDate from './parse-github-date'
|
||||
|
||||
const videoFeaturesApp = function (app, video) {
|
||||
|
|
@ -30,6 +31,10 @@ export default async function ( applist ) {
|
|||
const videos = []
|
||||
|
||||
for (const videoId in fetchedVideos) {
|
||||
|
||||
// Skip private videos
|
||||
if (fetchedVideos[videoId].title === 'Private video') continue
|
||||
|
||||
// Build video slug
|
||||
const slug = slugify(`${fetchedVideos[videoId].title}-i-${videoId}`, {
|
||||
lower: true,
|
||||
|
|
@ -61,7 +66,9 @@ export default async function ( applist ) {
|
|||
slug,
|
||||
timestamps: fetchedVideos[videoId].timestamps,
|
||||
thumbnails: fetchedVideos[videoId].rawData.snippet.thumbnails,
|
||||
endpoint: `/tv/${slug}`
|
||||
endpoint: getVideoEndpoint({
|
||||
slug
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import buildHomebrewList from './helpers/build-homebrew-list.js'
|
|||
import buildVideoList from './helpers/build-video-list.js'
|
||||
|
||||
import { categories } from './helpers/categories.js'
|
||||
import { getAppEndpoint } from './helpers/app-derived.js'
|
||||
import { getAppEndpoint, getVideoEndpoint } from './helpers/app-derived.js'
|
||||
|
||||
|
||||
const listsOptions = [
|
||||
|
|
@ -121,6 +121,8 @@ export default {
|
|||
...listsOptions,
|
||||
videoListOptions
|
||||
].map(async list => {
|
||||
// Read saved lists
|
||||
|
||||
const methodName = `Reading ${list.path}`
|
||||
console.time(methodName)
|
||||
|
||||
|
|
@ -146,8 +148,14 @@ export default {
|
|||
videoRoutes,
|
||||
homebrewRoutes
|
||||
] = lists.map((list, listI) => {
|
||||
|
||||
return list.map( app => {
|
||||
|
||||
const isVideo = (app.category === undefined)
|
||||
|
||||
if (isVideo) {
|
||||
return getVideoEndpoint(app)
|
||||
}
|
||||
|
||||
return getAppEndpoint(app)
|
||||
})
|
||||
})
|
||||
|
|
|
|||
|
|
@ -71,16 +71,22 @@ export default {
|
|||
},
|
||||
async asyncData ({ params: { slug } }) {
|
||||
|
||||
const { allVideoList } = await import('~/helpers/get-list.js')
|
||||
const { allVideoList: allVideoAppsList } = await import('~/helpers/get-list.js')
|
||||
const { default: videoList } = await import('~/static/video-list.json')
|
||||
|
||||
const featuredApps = []
|
||||
|
||||
// Find the video for our current page
|
||||
const video = videoList.find(video => (video.slug === slug))
|
||||
|
||||
for (const app of allVideoList) {
|
||||
console.log('video', video)
|
||||
|
||||
// Find the apps listed in this video
|
||||
for (const app of allVideoAppsList) {
|
||||
// Skip this app if it's not listed in the videos apps
|
||||
if (!video.apps.includes(app.slug)) continue
|
||||
|
||||
// Add this app to our featured app list
|
||||
featuredApps.push(app)
|
||||
}
|
||||
|
||||
|
|
@ -89,10 +95,13 @@ export default {
|
|||
// Find other videos that also feature this video's app
|
||||
for (const otherVideo of videoList) {
|
||||
for (const app of featuredApps) {
|
||||
// Skip if this app is not in the other video's apps
|
||||
if (!otherVideo.apps.includes(app.slug)) continue
|
||||
|
||||
// Skip if the other video is, in fact, this video
|
||||
if (otherVideo.slug === video.slug) continue
|
||||
|
||||
// Add this video to our related videos list
|
||||
relatedVideos.push(otherVideo)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue