@@ -828,6 +828,16 @@ def GET(self):
828828 type = "application/opds+json" ,
829829 templated = True ,
830830 ),
831+ Link (
832+ rel = "http://opds-spec.org/shelf" ,
833+ href = "https://archive.org/services/loans/loan/?action=user_bookshelf" ,
834+ type = "application/opds+json" ,
835+ ),
836+ Link (
837+ rel = "profile" ,
838+ href = "https://archive.org/services/loans/loan/?action=user_profile" ,
839+ type = "application/opds-profile+json" ,
840+ ),
831841 ],
832842 )
833843 web .header ('Content-Type' , 'application/opds+json' )
@@ -838,6 +848,8 @@ class opds_books(delegate.page):
838848 path = r"/opds/books/(OL\d+M)"
839849
840850 def GET (self , edition_olid : str ):
851+ from pyopds2 import Link
852+
841853 provider = get_opds_data_provider ()
842854 resp = provider .search (query = f'edition_key:{ edition_olid } ' )
843855 web .header ('Content-Type' , 'application/opds-publication+json' )
@@ -847,9 +859,20 @@ def GET(self, edition_olid: str):
847859 data = json .dumps ({'error' : 'Edition not found' }),
848860 )
849861
850- return delegate .RawText (
851- json .dumps (resp .records [0 ].to_publication ().model_dump ())
852- )
862+ pub = resp .records [0 ].to_publication ()
863+ pub .links += [
864+ Link (
865+ rel = "http://opds-spec.org/shelf" ,
866+ href = "https://archive.org/services/loans/loan/?action=user_bookshelf" ,
867+ type = "application/opds+json" ,
868+ ),
869+ Link (
870+ rel = "profile" ,
871+ href = "https://archive.org/services/loans/loan/?action=user_profile" ,
872+ type = "application/opds-profile+json" ,
873+ ),
874+ ]
875+ return delegate .RawText (json .dumps (pub .model_dump ()))
853876
854877
855878class opds_home (delegate .page ):
@@ -934,6 +957,16 @@ def build_homepage():
934957 type = "application/opds+json" ,
935958 templated = True ,
936959 ),
960+ Link (
961+ rel = "http://opds-spec.org/shelf" ,
962+ href = "https://archive.org/services/loans/loan/?action=user_bookshelf" ,
963+ type = "application/opds+json" ,
964+ ),
965+ Link (
966+ rel = "profile" ,
967+ href = "https://archive.org/services/loans/loan/?action=user_profile" ,
968+ type = "application/opds-profile+json" ,
969+ ),
937970 ],
938971 )
939972 return catalog .model_dump ()
0 commit comments