@@ -183,3 +183,32 @@ def load_metadata_from_youtube(video_id, request):
183183 logging .warning ('YouTube API key or video id is None. Please make sure API key and video id is not None' )
184184
185185 return metadata , status_code
186+
187+
188+ def get_resource_url (xblock , path , package_scope = None ):
189+ """
190+ Return the runtime URL for a static resource in this XBlock's package.
191+
192+ When the Django pipeline is enabled or REQUIRE_DEBUG is False, uses the
193+ pipeline path (e.g. {package_scope}/public/{path}). Otherwise uses the
194+ dev path (e.g. public/{path}). See platform's xblock_local_resource_url() in:
195+ openedx/core/lib/xblock_utils/__init__.py
196+
197+ Arguments:
198+ xblock: The XBlock instance (for runtime.local_resource_url).
199+ path (str): Relative path within the package, e.g. "css/video.css".
200+ package_scope (str): Package name prefix, e.g. "video". If None,
201+ both paths are "public/{path}"; otherwise pipeline adds the prefix.
202+
203+ Returns:
204+ str: URL from xblock.runtime.local_resource_url() for the resource.
205+ """
206+ pipeline_path = dev_path = f"public/{ path } "
207+ if package_scope :
208+ pipeline_path = f"{ package_scope } /{ pipeline_path } "
209+ pipeline = getattr (settings , 'PIPELINE' , {})
210+ if pipeline .get ('PIPELINE_ENABLED' , True ) or not getattr (settings , 'REQUIRE_DEBUG' , False ):
211+ resource_path = pipeline_path
212+ else :
213+ resource_path = dev_path
214+ return xblock .runtime .local_resource_url (xblock , resource_path )
0 commit comments