mirror of
https://git.sr.ht/~cadence/bibliogram
synced 2025-12-15 19:05:09 +00:00
Blocked by Instagram.
This commit is contained in:
@@ -55,7 +55,7 @@ class TtlCache {
|
||||
*/
|
||||
getTtl(key, factor = 1) {
|
||||
if (this.has(key)) {
|
||||
return Math.max((Math.floor(Date.now() - this.cache.get(key).time) / factor), 0)
|
||||
return Math.max(Math.ceil((this.cache.get(key).time + this.ttl - Date.now()) / factor), 0)
|
||||
} else {
|
||||
return null
|
||||
}
|
||||
|
||||
@@ -11,7 +11,8 @@ const timelineEntryCache = new TtlCache(constants.caching.resource_cache_time)
|
||||
function fetchUser(username) {
|
||||
return requestCache.getOrFetch("user/"+username, () => {
|
||||
return request(`https://www.instagram.com/${username}/`).then(res => {
|
||||
if (res.status === 404) throw constants.symbols.NOT_FOUND
|
||||
if (res.status === 302) throw constants.symbols.INSTAGRAM_DEMANDS_LOGIN
|
||||
else if (res.status === 404) throw constants.symbols.NOT_FOUND
|
||||
else return res.text().then(text => {
|
||||
// require down here or have to deal with require loop. require cache will take care of it anyway.
|
||||
// User -> Timeline -> TimelineImage -> collectors -/> User
|
||||
|
||||
@@ -37,7 +37,8 @@ let constants = {
|
||||
TYPE_GALLERY_IMAGE: Symbol("TYPE_GALLERY_IMAGE"),
|
||||
TYPE_GALLERY_VIDEO: Symbol("TYPE_GALLERY_VIDEO"),
|
||||
NOT_FOUND: Symbol("NOT_FOUND"),
|
||||
NO_SHARED_DATA: Symbol("NO_SHARED_DATA")
|
||||
NO_SHARED_DATA: Symbol("NO_SHARED_DATA"),
|
||||
INSTAGRAM_DEMANDS_LOGIN: Symbol("INSTAGRAM_DEMANDS_LOGIN")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,8 @@ function request(url) {
|
||||
return fetch(url, {
|
||||
headers: {
|
||||
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36"
|
||||
}
|
||||
},
|
||||
redirect: "manual"
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user