|
| 1 | +# |
| 2 | +# assets.py |
| 3 | +# pyblox |
| 4 | +# |
| 5 | +# By Sanjay-B(Sanjay Bhadra) |
| 6 | +# Copyright © 2017 Sanjay-B(Sanjay Bhadra). All rights reserved. |
| 7 | +# |
| 8 | + |
| 9 | +from .http import Http |
| 10 | +import json |
| 11 | + |
| 12 | + |
| 13 | +class Assets: |
| 14 | + |
| 15 | + def PackageAsset(assetid): |
| 16 | + a = Http.sendRequest("https://www.roblox.com/Game/GetAssetIdsForPackageId?packageId=" + str(assetid)) |
| 17 | + result = [] |
| 18 | + for part in a: |
| 19 | + i = a.index(part) |
| 20 | + b = part |
| 21 | + link = "https://www.roblox.com/library/" + str(b) |
| 22 | + result.insert(i, link) |
| 23 | + return result |
| 24 | + |
| 25 | + # GET https://api.roblox.com/Ownership/HasAsset?userId={userId}&assetId={assetId} |
| 26 | + # Returns Boolean |
| 27 | + def hasAsset(userid, assetid): |
| 28 | + a = Http.sendRequest( |
| 29 | + "https://api.roblox.com/Ownership/HasAsset?userId=" + str(userid) + "&assetId=" + str(assetid)) |
| 30 | + if a == "true" or True: |
| 31 | + return True |
| 32 | + else: |
| 33 | + return False |
| 34 | + |
| 35 | + # GET https://api.roblox.com/Marketplace/ProductInfo?assetId={assetId} |
| 36 | + # Returns Table/Array + Attributes |
| 37 | + def Asset(assetid): |
| 38 | + c = Http.sendRequest("https://api.roblox.com/Marketplace/ProductInfo?assetId=" + str(assetid)) |
| 39 | + b = c.decode("utf-8") |
| 40 | + a = json.loads(b) |
| 41 | + global Asset |
| 42 | + Asset = lambda: None |
| 43 | + Asset.Name = a["Name"] |
| 44 | + Asset.Id = a["AssetId"] |
| 45 | + Asset.ProductId = a["ProductId"] |
| 46 | + Asset.Description = a["Description"] |
| 47 | + Asset.AssetTypeId = a["AssetTypeId"] |
| 48 | + Asset.CreatorName = a["Creator"]["Name"] |
| 49 | + Asset.CreatorId = a["Creator"]["Id"] |
| 50 | + Asset.CreatorType = a["Creator"]["CreatorType"] |
| 51 | + Asset.CreatorTargetId = a["Creator"]["CreatorTargetId"] |
| 52 | + Asset.IconImageAssetId = a["IconImageAssetId"] |
| 53 | + Asset.Created = a["Created"] |
| 54 | + Asset.Updated = a["Updated"] |
| 55 | + Asset.PriceInRobux = a["PriceInRobux"] |
| 56 | + Asset.Sales = a["Sales"] |
| 57 | + Asset.IsNew = a["IsNew"] |
| 58 | + Asset.IsForSale = a["IsForSale"] |
| 59 | + Asset.IsPublicDomain = a["IsPublicDomain"] |
| 60 | + Asset.IsLimited = a["IsLimited"] |
| 61 | + Asset.IsLimitedUnique = a["IsLimitedUnique"] |
| 62 | + Asset.Remaining = a["Remaining"] |
| 63 | + Asset.MinimumMembershipLevel = a["MinimumMembershipLevel"] |
| 64 | + Asset.ContentRatingTypeId = a["ContentRatingTypeId"] |
| 65 | + return Asset |
| 66 | + |
| 67 | + # GET https://www.roblox.com/studio/plugins/info?assetId={assetId} |
| 68 | + # Returns Table/Array |
| 69 | + def AssetVersions(assetid): |
| 70 | + a = Http.sendRequest("https://www.roblox.com/studio/plugins/info?assetId=" + str(assetid)) |
| 71 | + result = [] |
| 72 | + for part in a: |
| 73 | + i = a.index(part) |
| 74 | + b = part |
| 75 | + result.insert(i, part) |
| 76 | + return result |
0 commit comments