Enter a Flickr URL, and find out what sort of URL it is (single photo, album, gallery, etc.)
Project description
flickr-url-parser
This is a library for parsing Flickr URLs. You enter a Flickr URL, and it tells you what it points to – a single photo, an album, a gallery, and so on.
Examples:
$ flickr_url_parser "https://www.flickr.com/photos/sdasmarchives/50567413447"
{"type": "single_photo", "photo_id": "50567413447"}
$ flickr_url_parser "https://www.flickr.com/photos/aljazeeraenglish/albums/72157626164453131"
{"type": "album", "user_url": "https://www.flickr.com/photos/aljazeeraenglish", "album_id": "72157626164453131", "page": 1}
$ flickr_url_parser "https://www.flickr.com/photos/blueminds/page3"
{"type": "user", "user_url": "https://www.flickr.com/photos/blueminds"}
Motivation
There's a lot of variety in Flickr URLs, even among URLs that point to the same thing. For example, all four of these URLs point to the same photo:
https://www.flickr.com/photos/sdasmarchives/50567413447
http://flickr.com/photos/49487266@N07/50567413447
https://www.flickr.com/photo.gne?id=50567413447
https://live.staticflickr.com/65535/50567413447_afec74ef45_o_d.jpg
Dealing with all these variants can be tricky – this library aims to simplify that. We use it for Flinumeratr, Flickypedia, and other Flickr Foundation projects.
Usage
There are two ways to use flickr_url_parser:
-
As a command-line tool. Run
flickr_url_parser
, passing the Flickr URL as a single argument:$ flickr_url_parser "https://www.flickr.com/photos/sdasmarchives/50567413447" {"type": "single_photo", "photo_id": "50567413447"}
The result will be printed as a JSON object.
To see more information about the possible return values, run
flickr_url_parser --help
. -
As a Python library. Import the function
parse_flickr_url
and pass the Flickr URL as a single argument:>>> from flickr_url_parser import parse_flickr_url >>> parse_flickr_url("https://www.flickr.com/photos/sdasmarchives/50567413447") {"type": "single_photo", "photo_id": "50567413447"}
To see more information about the possible return values, use the
help
function:>>> help(parse_flickr_url)
Note that just because a URL can be parsed does not mean it can be resolved to a photo and/or photos. The only way to know if there are photos behind the URL is to (1) try to fetch the URL or (2) use the output from the parser to ask the Flickr API for photos.
Development
If you want to make changes to the library, there are instructions in CONTRIBUTING.md.
Useful reading
- Photo Image URLs in the Flickr docs: https://www.flickr.com/services/api/misc.urls.html
License
This project is dual-licensed as Apache-2.0 and MIT.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file flickr_url_parser-1.10.0.tar.gz
.
File metadata
- Download URL: flickr_url_parser-1.10.0.tar.gz
- Upload date:
- Size: 21.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e9fc96f8a123f6e7c4bbd9cab8534cde1a09ea5091f4bf0adcbdf853ed72b609 |
|
MD5 | 4e1afb9dc5a1b789d4fe87134ab85ec0 |
|
BLAKE2b-256 | 4e178d54df03ec366d0aa179b698b1736d09d780e25d8c55d1e6be93063eaefd |
File details
Details for the file flickr_url_parser-1.10.0-py3-none-any.whl
.
File metadata
- Download URL: flickr_url_parser-1.10.0-py3-none-any.whl
- Upload date:
- Size: 16.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c3b39ad3c6897d6581ac64516eb7745b44ea4ad69ba3fee675d9b541d0b925b5 |
|
MD5 | f5c3add2c392be250075082354b7b296 |
|
BLAKE2b-256 | 5385e21d0e4df10ce9902c620269a484328864705e601dcf2c9f3846c886ae4a |