Python SDK for publishing media on the Slike platform via JSON-RPC API.
Install the package using pip:
pip install slikemedia- Python 3.7 or higher
- requests >= 2.25.0
from slikemedia import PublishMediaOnSlike
# Basic usage - defaults to production
result = PublishMediaOnSlike(
url="https://drive.google.com/file/d/YOUR_FILE_ID/view",
title="My Video Title",
description="My video description",
type="gdrive",
token="your-token-here"
)
print(result)from slikemedia import PublishMediaOnSlike
# Production is the default - no environment parameter needed
result = PublishMediaOnSlike(
url="https://drive.google.com/file/d/1knH6zj4KAL_IfHxf6z-lhx6hd107X9jK/view",
title="Production Video",
description="Production video description",
type="gdrive",
token="your-production-token" # Uses b2b.sli.ke (production)
)from slikemedia import PublishMediaOnSlike
result = PublishMediaOnSlike(
url="https://drive.google.com/file/d/1knH6zj4KAL_IfHxf6z-lhx6hd107X9jK/view",
title="Test Video",
description="Test video description",
type="gdrive",
token="your-production-token",
token_dev="your-dev-token",
environment="dev" # Uses local.sli.ke:8443 with token_dev
)from slikemedia import PublishMediaOnSlike
result = PublishMediaOnSlike(
url="https://drive.google.com/file/d/1knH6zj4KAL_IfHxf6z-lhx6hd107X9jK/view",
title="Video with Tags",
description="Video with additional metadata",
type="gdrive",
token="your-production-token",
tags=["tutorial", "python"],
asset_type="shorts",
preset_meta="preset_id_123",
auto_publish=True
)from slikemedia import PublishMediaOnSlike, SlikeAPIError
try:
result = PublishMediaOnSlike(
url="https://drive.google.com/file/d/YOUR_FILE_ID/view",
title="My Video",
description="My description",
type="gdrive",
token="your-token"
)
print("Success:", result)
except ValueError as e:
print("Validation error:", e)
except SlikeAPIError as e:
print("API error:", e)Publish media to the Slike platform.
- url (str, required): Media URL (Google Drive, YouTube, etc.)
- title (str, required): Media title
- description (str, required): Media description
- type (str, required): Media type (e.g., 'gdrive', 'youtube')
- token (str, required): Production authentication token (uses
b2b.sli.ke) - token_dev (str, optional): Development authentication token (used when environment is "dev" or "development")
- environment (str, optional): Environment - "production"/"prod" or "development"/"dev" (default: production)
- preset_meta (str, optional): Preset metadata identifier
- tags (List[str], optional): List of tags for the media
- asset_type (str, optional): Asset type (e.g., 'shorts', 'video')
- auto_publish (bool, optional): Whether to auto-publish the media (default: True)
- Dict[str, Any]: API response containing the result of the publish operation
- ValueError: If required parameters are invalid or missing
- SlikeAPIError: If the API request fails
- Production (default): If
environmentis not specified or set toNone, the request will be sent to production (https://b2b.sli.ke/rpc) using thetokenparameter - Development: Set
environment="dev"orenvironment="development"to use the development environment (https://local.sli.ke:8443/rpc) with thetoken_devparameter - When
environmentis set to "dev"/"development", thetoken_devparameter is required - URLs are configured as constants at the top of the module:
PRODUCTION_URL = "https://b2b.sli.ke/rpc"DEVELOPMENT_URL = "https://local.sli.ke:8443/rpc"
Custom exception class for Slike API errors. Inherits from the standard Exception class.
# Clone the repository
git clone https://github.com/yourusername/slikemedia.git
cd slikemedia
# Install in editable mode
pip install -e .# Install hatch if not already installed
pip install hatch
# Build the package
hatch build# Run the test script
python test_slikemedia.pyThis project is licensed under the MIT License - see the LICENSE file for details.
For issues, questions, or contributions, please visit the GitHub repository.