def get_relative_url(self, url: URL, resource: "ExportedResource", content_type: str = None) -> URL: # Express URLs as paths relative to the exported document url_export_path = self.export.destination.get_export_path( url, content_type=content_type) i = 0 for a, b in zip_longest(resource.export_folder, url_export_path): if a != b: break i += 1 url_export_path = url_export_path[i:] for n in range(len(resource.export_folder) - i): url_export_path.insert(0, u"..") return URL(path=url_export_path, query=url.query, fragment=url.fragment)
def get_uri(self, **kwargs): return URL(self.uri_pattern % (self.video_id,))
def get_base_url(self, url: URL) -> URL: if len(url.path) > 1: return url.copy(path=url.path.pop(-1)) else: return url