Advertisement
xtekky_

Untitled

Jul 25th, 2022
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 6.10 KB | None | 0 0
  1. from ..utils.gorgon import Xgorgon
  2. import requests, urllib.parse, time, random, uuid, hashlib
  3.  
  4. class Viewbot:
  5.     def __init__(self, item_id):
  6.         self.item_id = item_id
  7.        
  8.         self.sdk_version = "2"
  9.         self.passport_sdk_version = "19"
  10.         self.xtt_dm_status = "login=0;ct=0"
  11.         self.host = "api16-va.tiktokv.com"
  12.         self.user_agent = "okhttp/3.10.0.1"
  13.         self.app_version = "19.1.3"
  14.  
  15.         self.devices = [
  16.             "SM-E426B",
  17.             "SM-M326B",
  18.             "SM-A528B",
  19.             "SM-F711B",
  20.             "SM-F926B",
  21.             "SM-A037G",
  22.             "SM-A225F",
  23.             "SM-A226B",
  24.             "SM-M426B",
  25.             "SM-A525F",
  26.         ]
  27.        
  28.     def unix(self, spoof: int = 0) -> str:
  29.         if spoof == 0:
  30.             _unix = str(int(time.time()))
  31.         else:
  32.             _unix = str(round(time.time(), spoof)).replace(".", "")
  33.         return _unix
  34.    
  35.     def params(self):
  36.        
  37.         params = {
  38.             "passport-sdk-version": self.passport_sdk_version,
  39.             "os_api": "25",
  40.             "device_type": random.choices(self.devices),
  41.             "ssmix": "a",
  42.             "manifest_version_code": "2021901030",
  43.             "dpi": "320",
  44.             "carrier_region": "IE",
  45.             "uoo": "0",
  46.             "region": "US",
  47.             "carrier_region_v2": "310",
  48.             "app_name": "musical_ly",
  49.             "version_name": self.app_version,
  50.             "timezone_offset": "7200",
  51.             "ts": self.unix(),
  52.             "ab_version": self.app_version,
  53.             "cpu_support64": "false",
  54.             "ac2": "wifi",
  55.             "ac": "wifi",
  56.             "app_type": "normal",
  57.             "host_abi": "armeabi-v7a",
  58.             "channel": "googleplay",
  59.             "update_version_code": "2021901030",
  60.             "_rticket": self.unix(spoof=3),
  61.             "device_platform": "android",
  62.             "iid": random.randint(1000000000000000000, 9999999999999999999),
  63.             "build_number": self.app_version,
  64.             "locale": "en",
  65.             "op_region": "IE",
  66.             "version_code": str(self.app_version).replace(".", "0"),
  67.             "timezone_name": "Africa/Harare",
  68.             "cdid": str(uuid.uuid4()),
  69.             "openudid": "0e96eaebc0c2e44f",
  70.             "device_id": random.randint(1000000000000000000, 9999999999999999999),
  71.             "sys_region": "US",
  72.             "app_language": "en",
  73.             "resolution": "900*1600",
  74.             "device_brand": "samsung",
  75.             "language": "en",
  76.             "os_version": "7.1.2",
  77.             "aid": "1233",
  78.             "mcc_mnc": "31002",
  79.         }
  80.        
  81.         return str(urllib.parse.urlencode(params))
  82.    
  83.     def data(self):
  84.         payload = (
  85.             f"item_id={self.item_id}"
  86.                 + "&sync_origin=false"
  87.                 + "&first_install_time=1653681371"
  88.                 + "&pre_item_playtime=2968"
  89.                 + "&follower_status=0"
  90.                 + "&pre_hot_sentence="
  91.                 # +"&pre_item_id=7120300037371989254"
  92.                 + "&play_delta=1"
  93.                 + f"&action_time={self.unix()}"
  94.                 + "&aweme_type=0"
  95.                 + "&tab_type=1"
  96.                 + "&follow_status=1"
  97.         )
  98.        
  99.         return payload
  100.    
  101.     def stub(self, data: str):
  102.         _stub = str(hashlib.md5(data.encode()).hexdigest()).upper()
  103.         return _stub
  104.  
  105.     def headers(self, params: str, data: str):
  106.         headers = {
  107.             "x-ss-stub": self.stub(data = data),
  108.             "accept-encoding": "gzip",
  109.             "passport-sdk-version": self.passport_sdk_version,
  110.             #"x-tt-token": "0315b7d97b63b1a54be355352b21a58431007e64e9ff02986394452a0883bd19ca69f584032c0b141496d5903389d64eb707a588dca52a71aaf54a8b1b3469416d2fd3d9ddcfe84c2c65d220a825384c0eaa90683d5e3440c1118fcf1785f3c39d1d8-1.0.1",
  111.             "sdk-version": "2",
  112.             "x-ss-req-ticket": self.unix(spoof=3),
  113.             "x-tt-dm-status": self.xtt_dm_status,
  114.             "x-tt-cmpl-token": "AgQQAPObF-RPsI8CtPIKJt0_xfZsL4wdv4BpYMYuRA",
  115.             #"cookie": "passport_csrf_token=c8ab7ab8f0bfe9eb1e1e2f8eaaab5aba; passport_csrf_token_default=c8ab7ab8f0bfe9eb1e1e2f8eaaab5aba; d_ticket=f4cea49a3aeec80297f50ee07cfa97fe07649; multi_sids=6862459255506863110%3A15b7d97b63b1a54be355352b21a58431; odin_tt=0c0e829a67df59990bd7535a5d4e8f1767b07c6a01875c967010fc90bbc083cd6589088714205a5a42861a7bbe6fd9ea1914c5bb490d2cbfd79ae69947cc3595074b93c1e8262159948dab261eb2e405; cmpl_token=AgQQAPObF-RPsI8CtPIKJt0_xfZsL4wdv4AQYMYr9A; sid_guard=15b7d97b63b1a54be355352b21a58431%7C1658188812%7C15552000%7CSun%2C+15-Jan-2023+00%3A00%3A12+GMT; uid_tt=e3b2ee40c76dc2b3ba5cdaef5dfa151e54bf33436d47c2b74e4f18ce4c532f13; uid_tt_ss=e3b2ee40c76dc2b3ba5cdaef5dfa151e54bf33436d47c2b74e4f18ce4c532f13; sid_tt=15b7d97b63b1a54be355352b21a58431; sessionid=15b7d97b63b1a54be355352b21a58431; sessionid_ss=15b7d97b63b1a54be355352b21a58431; store-idc=maliva; store-country-code=fr; tt-target-idc=useast1a; install_id=7121866431746524933; ttreq=1$f5f02d84a48df26a5e69335d07d1b9787aebdb3a; msToken=h2FGrgD2vEz_s6GrKKO8rjL8LiSGePBNKMbqmTaqkuEuG4uBTD4BnxfzaPTCNb-dVElJ_JoX2ch_miTwgLK-3K-rdgLX5p01VPLqQSw-h66YCXODbkmbdw==",
  116.             "content-type": "application/x-www-form-urlencoded; charset=UTF-8",
  117.             "host": self.host,
  118.             "connection": "Keep-Alive",
  119.             "user-agent": self.user_agent,
  120.         }
  121.        
  122.         xg = Xgorgon(
  123.             params=params,
  124.             data=data,
  125.             cookies=None
  126.         ).get_value()
  127.  
  128.         headers["x-gorgon"] = xg["X-Gorgon"]
  129.         headers["x-khronos"] = xg["X-Khronos"]
  130.        
  131.         return headers
  132.  
  133.  
  134.     def __main__(self):
  135.         params = self.params()
  136.         data = self.data()
  137.  
  138.         url = (
  139.             "https://"
  140.             + "api16-va.tiktokv.com"
  141.             + "/aweme/v1/aweme/stats/?"
  142.             + params
  143.         )
  144.        
  145.         req = requests.get(
  146.             url = url,
  147.             headers = self.headers(params, data),
  148.             data = data
  149.            
  150.         )
  151.  
  152. if __name__ == "__main__":
  153.     Viewbot(item_id="")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement