Skip to content

Instantly share code, notes, and snippets.

@io7m
Created February 2, 2022 16:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save io7m/a1ccd3360c12f2ce89984ed55c6f87b3 to your computer and use it in GitHub Desktop.
Save io7m/a1ccd3360c12f2ce89984ed55c6f87b3 to your computer and use it in GitHub Desktop.

Initial DRM schemes and content types in database order:

[
  {
    "drm": "application/vnd.adobe.adept+xml",
    "type": "application/epub+zip"
  },
  {
    "drm": "Libby DRM",
    "type": "application/vnd.overdrive.circulation.api+json;profile=audiobook"
  },
  {
    "type": "application/audiobook+json"
  },
  {
    "drm": "application/vnd.librarysimplified.bearer-token+json",
    "type": "application/pdf"
  },
  {
    "drm": "application/vnd.librarysimplified.bearer-token+json",
    "type": "application/epub+zip"
  },
  {
    "type": "application/epub+zip"
  },
  {
    "type": "application/pdf"
  },
  {
    "drm": "application/vnd.librarysimplified.findaway.license+json"
  },
  {
    "drm": "application/vnd.librarysimplified.bearer-token+json",
    "type": "application/audiobook+json"
  },
  {
    "type": "application/kepub+zip"
  },
  {
    "type": "application/x-mobipocket-ebook"
  },
  {
    "type": "application/x-mobi8-ebook"
  },
  {
    "type": "text/plain; charset=utf-8"
  },
  {
    "type": "application/octet-stream"
  },
  {
    "type": "text/html; charset=utf-8"
  },
  {
    "drm": "http://www.feedbooks.com/audiobooks/access-restriction",
    "type": "application/audiobook+json"
  },
  {
    "drm": "application/vnd.readium.lcp.license.v1.0+json",
    "type": "application/audiobook+lcp"
  },
  {
    "drm": "application/vnd.readium.lcp.license.v1.0+json",
    "type": "application/epub+zip"
  }
]

We then specify that we want this DRM and content type configuration:

FormatPriorities(
	prioritized_drm_schemes=[
		"application/vnd.readium.lcp.license.v1.0+json",
		"application/vnd.librarysimplified.bearer-token+json",
		"application/vnd.adobe.adept+xml",
	],
	prioritized_content_types=[
		"application/epub+zip",
		"application/audiobook+json",
		"application/audiobook+lcp" 
		"application/pdf",
	],
	hidden_content_types=[
		"application/x-mobipocket-ebook",
		"application/x-mobi8-ebook",
		"application/kepub+zip",
		"text/plain; charset=utf-8",
		"application/octet-stream",
		"text/html; charset=utf-8"
	],
)

After filtering and prioritization:

[
  {
    "type": "application/epub+zip"
  },
  {
    "type": "application/audiobook+json"
  },
  {
    "type": "application/pdf"
  },
  {
    "drm": "application/vnd.readium.lcp.license.v1.0+json",
    "type": "application/epub+zip"
  },
  {
    "drm": "application/vnd.readium.lcp.license.v1.0+json",
    "type": "application/audiobook+lcp"
  },
  {
    "drm": "application/vnd.librarysimplified.bearer-token+json",
    "type": "application/epub+zip"
  },
  {
    "drm": "application/vnd.librarysimplified.bearer-token+json",
    "type": "application/audiobook+json"
  },
  {
    "drm": "application/vnd.librarysimplified.bearer-token+json",
    "type": "application/pdf"
  },
  {
    "drm": "application/vnd.adobe.adept+xml",
    "type": "application/epub+zip"
  },
  {
    "drm": "http://www.feedbooks.com/audiobooks/access-restriction",
    "type": "application/audiobook+json"
  },
  {
    "drm": "Libby DRM",
    "type": "application/vnd.overdrive.circulation.api+json;profile=audiobook"
  },
  {
    "drm": "application/vnd.librarysimplified.findaway.license+json"
  }
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment