-
Notifications
You must be signed in to change notification settings - Fork 3
/
t.pyw
58 lines (46 loc) · 1.85 KB
/
t.pyw
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import requests
import tweepy
import json
import yaml
from pathlib import Path
import time
yaml_file = open("config.yaml", 'r')
yaml_content = yaml.load(yaml_file, Loader = yaml.FullLoader)
consumer_key = yaml_content["consumer_key"]
consumer_secret = yaml_content["consumer_secret"]
access_token = yaml_content["access_token"]
access_token_secret = yaml_content["access_token_secret"]
channelId = yaml_content["channelID"]
try:
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token,access_token_secret)
api = tweepy.API(auth)
except Exception as e:
exit(-1)
for number_of_tries in range(5):
try:
json = requests.post("http://localhost:5279", json={"method": "claim_search", "params": {"channel": channelId,
"stream_types": ["video",
"document"],
"order_by": ["release_time"]}}).json()
items = json["result"]["items"]
except:
time.sleep(5)
continue
for item in items:
claimId = item["claim_id"]
title = item["value"]["title"]
url = item["permanent_url"]
name = item['name']
break
Path("last_claim_id.txt").touch()
lastClaimId = open("last_claim_id.txt", "r").read()
if(claimId != lastClaimId):
try:
api.update_status('I am free at LBRY, check my last content and join us '"https://lbry.tv/"+ channelId +"/"+ name+ ":"+claimId)
f = open("last_claim_id.txt", "w")
f.write(claimId)
f.close()
except:
exit(-1)
exit(0)