简体   繁体   English

从Flickr中提取有限的标记照片

[英]Pulling limited tagged photos from Flickr

So I've got a hobby site I'm working on. 因此,我有一个正在工作的业余网站。 I've got items that are tagged and I want to associate those items with photos from Flickr. 我有带标签的项目,我想将这些项目与Flickr的照片相关联。 Even with restrictive searches, I might get results numbering in the thousands. 即使进行限制性搜索,我也可能获得成千上万个结果。

Requirements: 要求:

  1. I want to display between 10-20 pictures but I want to randomize the photos each time. 我想显示10到20张图片,但每次都希望将照片随机化。
  2. I don't want to hit Flickr every time a page request is made. 我不想每次发出页面请求时都点击Flickr。
  3. Not every Flickr photo with the same tags as my item will be relevant. 并非每张带有与我的物品相同标签的Flickr照片都是相关的。

How should I store that number of results and how would I determine which ones are relevant? 我应该如何存储该数量的结果,以及如何确定哪些结果是相关的?

I would suggest moving the code that selects, randomizes, downloads and caches photos to separate service. 我建议将选择,随机化,下载和缓存照片的代码移到单独的服务中。 It could be locally accessible REST application. 它可以是本地可访问的REST应用程序。 Keep your core code clean and don't clutter it with remote operations and retention policy. 保持核心代码干净,不要因远程操作和保留策略而混乱。

  1. Build tags-to-images map and store it locally, in file or database. 构建标签到图像映射并将其本地存储在文件或数据库中。 Randomizing array is easy in both cases. 在两种情况下,随机化数组都很容易。
  2. Point image src to local cache. 将图像src指向本地缓存。 Clean cache periodically, depending on your hosting capacity. 定期清理缓存,具体取决于您的主机容量。
  3. Whitelist or blacklist photos to filter them in step 1. 将照片列入白名单或黑名单以在步骤1中对其进行过滤。

Your best bet for parts 1 and 2 is to make a large request, say returning 100 or 200 photos and store the URL and other details. 对于第1部分和第2部分,最好的选择是提出一个大请求,例如返回100或200张照片,并存储URL和其他详细信息。 Then producing random selections from your local copy should be simple. 然后从本地副本产生随机选择应该很简单。

For part 3 I'm not sure how you would accomplish this without some form of human intervention, unless you can define 'relevant' in some terms you can program against. 对于第3部分,我不确定在没有某种形式的人工干预的情况下如何实现此目标,除非您可以用一些可以定义的术语定义“相关”。

If human intervention is fine then obviously they can browse your local copy of photos and pick relevant ones (or discard un-relevant ones). 如果人工干预很好,那么显然他们可以浏览您的本地照片副本并选择相关的照片(或丢弃不相关的照片)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM