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