#links #preview #metadata #fetching #url #image #shorturls

bin+lib preview-rs

A (simple) crate for fetching preview metadata from shorturls and links

4 releases

0.1.3 Sep 11, 2022
0.1.2 Sep 11, 2022
0.1.1 Sep 5, 2022
0.1.0 Sep 5, 2022

#28 in #preview

MIT license

13KB
214 lines

Preview-rs

A rust crate to fetch preview metadata for a URL.

Things left to be done:

  • More fallback options especially for images.
  • Support more multimedia options than images (video, png, etc).
  • Allow passing custom user-agent in the request.

Usage

    let prev = preview_rs::Preview::new("https://deezer.com");
    let preview = prev.fetch_preview();
    println!("Here is the preview of this URL: {:?}", &preview);

    /** PreviewResponse {
       description: Some("You bring the passion, we bring the music! Access more than 73 million tracks, anytime, anywhere!"),
       title: Some("Deezer | Listen to music | Online music streaming platform"),
       url: Some("http://www.deezer.com"),
       name: Some("Deezer"),
       image: Some("https://e-cdns-files.dzcdn.net/img/common/opengraph-logo.png")
     }
     **/

Dependencies

~8–20MB
~283K SLoC