summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOmar Roth <omarroth@hotmail.com>2018-03-16 23:01:35 -0500
committerOmar Roth <omarroth@hotmail.com>2018-03-16 23:01:35 -0500
commit2be57276a27308e9e0619729905273eb285770b7 (patch)
treee351a95738cab4190720e0a8498f77654c19c3b8
parent36b184d1fbbef430f772f4655df076982e35762e (diff)
downloadinvidious-2be57276a27308e9e0619729905273eb285770b7.tar.gz
invidious-2be57276a27308e9e0619729905273eb285770b7.tar.bz2
invidious-2be57276a27308e9e0619729905273eb285770b7.zip
Add refresh for top videos
-rw-r--r--src/helpers.cr2
-rw-r--r--src/invidious.cr9
2 files changed, 5 insertions, 6 deletions
diff --git a/src/helpers.cr b/src/helpers.cr
index 31893603..6a707734 100644
--- a/src/helpers.cr
+++ b/src/helpers.cr
@@ -183,8 +183,8 @@ def get_video(id, client, db, refresh = true)
# If record was last updated over an hour ago, refresh (expire param in response lasts for 6 hours)
if refresh && Time.now - video.updated > 1.hours
- video = fetch_video(id, client)
db.exec("DELETE FROM videos * WHERE id = $1", id)
+ video = fetch_video(id, client)
args = arg_array(video.to_a)
db.exec("INSERT INTO videos VALUES (#{args})", video.to_a)
end
diff --git a/src/invidious.cr b/src/invidious.cr
index 617915c2..41544f9e 100644
--- a/src/invidious.cr
+++ b/src/invidious.cr
@@ -145,11 +145,10 @@ spawn do
videos = [] of Video
- PG_DB.query("SELECT * FROM videos d INNER JOIN (VALUES #{args}) v(id) USING (id)", top) do |rs|
- rs.each do
- video = rs.read(Video)
- videos << video
- end
+ top.each do |id|
+ client = get_client(youtube_pool)
+ videos << get_video(id, client, PG_DB)
+ youtube_pool << client
end
top_videos = videos
class='logmsg'> 2021-04-21Update French translationOlivier Humbert 2021-04-21Add newline at end of file for 'el' and 'zh-TW'Samantaz Fox 2021-04-21Minor fixes in locales after synchronizationSamantaz Fox 2021-04-21Add missing fields to locales (part 6)Samantaz Fox Updated da.json (Danish) Updated de.json (German) Updated eo.json (Esperando) Updated es.json (Spanigh) Updated nb-NO.json (Norvegian) Updated nl.json (Dutch) Updated pl.json (Polish) Updated pt-BR.json (Portuguese, Brasil) Updated ro.json (Romanian) Updated ru.json (Russian) Updated sv-SE.json (Swedish) Updated uk.json (Ukrainian) Updated zh-CN.json (Chinese, China) 2021-04-21Add missing fields to locales (part 5)Samantaz Fox * Also includes minor fixes when I could (french, italian, icelandic) * Added a new line at the end of en-US translation. Updated ar.json (Arabic) Updated el.json (Greek) Updated fa.json (Persian) Updated fr.json (French) Updated is.json (Icelandic) Updated it.json (Italian) Updated tr.json (Turkish) Updated zh-TW.json (Chinese, Taiwan) 2021-04-21Make the linter happy, againSamantaz Fox 2021-04-21Add missing fields to locales (part 4)Samantaz Fox Updated el.json (Greek) Updated fa.json (Persian) Updated fi.json (Finnish) Updated it.json (Italian) Updated pt-PT.json (Portuguese, Portugal) Updated zh-TW.json (Chinese, Taiwan) 2021-04-21Add missing fields to locales (part 3)Samantaz Fox Updated el.json (Greek) Updated fa.json (Persian) Updated fi.json (Finnish) Updated it.json (Italian) Updated pt-PT.json (Portuguese, Portugal) Updated sv-SE.json (Swedish) Updated tr.json (Turkish) Updated uk.json (Ukrainian) Updated zh-CN.json (Chinese, China) Updated zh-TW.json (Chinese, Taiwan) 2021-04-21Add missing fields to locales (part 2)Samantaz Fox Updated ja.json (Japanese) Updated nb-NO.json (Norwegian Bokmål) Updated nl.json (Dutch) Updated pl.json (Polish) Updated pt-BR.json (Portuguese, Brazil) Updated ro.json (Romanian) Updated ru.json (Russian) 2021-04-21Add missing fields to locales (part 1)Samantaz Fox Updated ar.json (Arabic) Updated de.json (German) Updated eo.json (Esperanto) Updated es.json (Spanish) Updated fr.json (French) Updated hr.json (Hungarian) Updated id.json (Indonesian) Updated is.json (Icelandic)