Compare commits
3 Commits
b4fbc705ed
...
4fe3e10656
Author | SHA1 | Date |
---|---|---|
gg | 4fe3e10656 | |
pta | 2d1c05baa4 | |
pta | d352ebbc17 |
|
@ -37,6 +37,7 @@ using DataFrames
|
||||||
s |> DataFrame
|
s |> DataFrame
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Install `yt-dlp`. Optionally install `jq` for pretty-printing and exploring json on the command line.
|
||||||
|
|
||||||
## Scripts
|
## Scripts
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
ALTER TABLE schedule
|
||||||
|
ADD COLUMN view_count INTEGER;
|
|
@ -108,7 +108,7 @@ function iswnl(title)
|
||||||
end
|
end
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Find the current live video's id and update the schedule table if a corresponding row can be found.
|
Fetch upcoming live videos' IDs and update the schedule table's corresponding rows.
|
||||||
|
|
||||||
# Examples
|
# Examples
|
||||||
```jldoctest
|
```jldoctest
|
||||||
|
@ -120,9 +120,17 @@ function update_schedule_with_live_video(db)
|
||||||
for v in vids
|
for v in vids
|
||||||
if iswnl(v[:title])
|
if iswnl(v[:title])
|
||||||
jst = wnl_title_to_jst(v[:title])
|
jst = wnl_title_to_jst(v[:title])
|
||||||
DB.update_schedule_with_video(db, string(jst), v[:id])
|
views =
|
||||||
|
if v[:live_status] == "was_live"
|
||||||
|
v[:view_count]
|
||||||
|
elseif v[:live_status] == "is_live"
|
||||||
|
v[:concurrent_view_count]
|
||||||
|
else # "is_upcoming"
|
||||||
|
0
|
||||||
|
end
|
||||||
|
DB.update_schedule_with_video(db, string(jst), v[:id], views)
|
||||||
if hour(jst) == 23
|
if hour(jst) == 23
|
||||||
DB.update_schedule_with_video(db, string(jst + Hour(1)), v[:id])
|
DB.update_schedule_with_video(db, string(jst + Hour(1)), v[:id], views)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
continue
|
continue
|
||||||
|
|
11
src/db.jl
11
src/db.jl
|
@ -91,14 +91,17 @@ function find_schedule_by_jst(db, jst)
|
||||||
end
|
end
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Update a schedule row with its `video_id`.
|
Update a schedule row with its `video_id` and `view_count`.
|
||||||
|
|
||||||
This function is for WN videos only, and it should skip over au PAY videos.
|
This function is for WN videos only, and it should skip over au PAY videos.
|
||||||
"""
|
"""
|
||||||
function update_schedule_with_video(db, jst, video_id)
|
function update_schedule_with_video(db, jst, video_id, view_count)
|
||||||
try
|
try
|
||||||
sql_update = "UPDATE schedule SET video_id = ? WHERE jst = ? AND segment_id NOT IN (8)"
|
sql_update = """
|
||||||
return DBInterface.execute(db, sql_update, [video_id, jst])
|
UPDATE schedule SET video_id = ?, view_count = ?
|
||||||
|
WHERE jst = ? AND segment_id NOT IN (8);
|
||||||
|
"""
|
||||||
|
return DBInterface.execute(db, sql_update, [video_id, view_count, jst])
|
||||||
catch e
|
catch e
|
||||||
@debug e
|
@debug e
|
||||||
return e
|
return e
|
||||||
|
|
Loading…
Reference in New Issue