Spaces:
Runtime error
Runtime error
Commit
·
d71f362
1
Parent(s):
c82b947
Update app.py
Browse files
app.py
CHANGED
@@ -1,100 +1,100 @@
|
|
1 |
-
# from git import Repo
|
2 |
-
import os
|
3 |
-
import streamlit as st
|
4 |
-
import dateutil
|
5 |
-
import datetime
|
6 |
|
7 |
-
import translators as ts
|
8 |
-
import translators.server as tss
|
9 |
-
import random
|
10 |
-
import tweepy
|
11 |
-
import time
|
12 |
-
import json
|
13 |
|
14 |
-
time_now = datetime.datetime.now()
|
15 |
-
last_minute = time_now - dateutil.relativedelta.relativedelta(minutes=1)
|
16 |
|
17 |
-
# st.set_page_config(
|
18 |
-
# page_title="TRACING INSIGHTS",
|
19 |
-
# page_icon=None,
|
20 |
-
# layout="wide",
|
21 |
-
# #initial_sidebar_state="expanded",
|
22 |
-
# # menu_items={
|
23 |
-
# # 'Get Help': 'https://www.extremelycoolapp.com/help',
|
24 |
-
# # 'Report a bug': "https://www.extremelycoolapp.com/bug",
|
25 |
-
# # 'About': "# This is a header. This is an *extremely* cool app!"
|
26 |
-
# # }
|
27 |
-
# )
|
28 |
|
29 |
-
st.write("Hello world!")
|
30 |
|
31 |
|
32 |
|
33 |
-
GITHUB_PAT = os.environ['GITHUB']
|
34 |
-
api_key = os.environ['api_key']
|
35 |
-
secret_api_key = os.environ['secret_api_key']
|
36 |
-
access_token = os.environ['access_token']
|
37 |
-
secret_access_token = os.environ['secret_access_token']
|
38 |
-
bearer_token = os.environ['bearer_token']
|
39 |
|
40 |
-
# if not os.path.exists('repo_directory'):
|
41 |
-
# Repo.clone_from(f'https://tracinginsights:{GITHUB_PAT}@github.com/TracingInsights/translator.git', 'repo_directory' )
|
42 |
|
43 |
-
# from repo_directory import translator
|
44 |
-
# translator.auth(api_key,secret_api_key,access_token,secret_access_token)
|
45 |
|
46 |
|
47 |
|
48 |
|
49 |
|
50 |
|
51 |
-
# works with tweets and replies too
|
52 |
|
53 |
|
54 |
-
def translate(bearer_token,api_key,secret_api_key,access_token,secret_access_token):
|
55 |
-
|
56 |
-
|
57 |
|
58 |
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
|
78 |
-
|
79 |
-
|
80 |
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
translate(bearer_token,api_key,secret_api_key,access_token,secret_access_token)
|
98 |
|
99 |
|
100 |
|
|
|
1 |
+
# # from git import Repo
|
2 |
+
# import os
|
3 |
+
# import streamlit as st
|
4 |
+
# import dateutil
|
5 |
+
# import datetime
|
6 |
|
7 |
+
# import translators as ts
|
8 |
+
# import translators.server as tss
|
9 |
+
# import random
|
10 |
+
# import tweepy
|
11 |
+
# import time
|
12 |
+
# import json
|
13 |
|
14 |
+
# time_now = datetime.datetime.now()
|
15 |
+
# last_minute = time_now - dateutil.relativedelta.relativedelta(minutes=1)
|
16 |
|
17 |
+
# # st.set_page_config(
|
18 |
+
# # page_title="TRACING INSIGHTS",
|
19 |
+
# # page_icon=None,
|
20 |
+
# # layout="wide",
|
21 |
+
# # #initial_sidebar_state="expanded",
|
22 |
+
# # # menu_items={
|
23 |
+
# # # 'Get Help': 'https://www.extremelycoolapp.com/help',
|
24 |
+
# # # 'Report a bug': "https://www.extremelycoolapp.com/bug",
|
25 |
+
# # # 'About': "# This is a header. This is an *extremely* cool app!"
|
26 |
+
# # # }
|
27 |
+
# # )
|
28 |
|
29 |
+
# st.write("Hello world!")
|
30 |
|
31 |
|
32 |
|
33 |
+
# GITHUB_PAT = os.environ['GITHUB']
|
34 |
+
# api_key = os.environ['api_key']
|
35 |
+
# secret_api_key = os.environ['secret_api_key']
|
36 |
+
# access_token = os.environ['access_token']
|
37 |
+
# secret_access_token = os.environ['secret_access_token']
|
38 |
+
# bearer_token = os.environ['bearer_token']
|
39 |
|
40 |
+
# # if not os.path.exists('repo_directory'):
|
41 |
+
# # Repo.clone_from(f'https://tracinginsights:{GITHUB_PAT}@github.com/TracingInsights/translator.git', 'repo_directory' )
|
42 |
|
43 |
+
# # from repo_directory import translator
|
44 |
+
# # translator.auth(api_key,secret_api_key,access_token,secret_access_token)
|
45 |
|
46 |
|
47 |
|
48 |
|
49 |
|
50 |
|
51 |
+
# # works with tweets and replies too
|
52 |
|
53 |
|
54 |
+
# def translate(bearer_token,api_key,secret_api_key,access_token,secret_access_token):
|
55 |
+
# # update users when you want to include more accounts
|
56 |
+
# users = [1568348454619070465,2755544640, 1030481714, 407048032,227265199,190632194, 149542215,127854979, 106170617]
|
57 |
|
58 |
|
59 |
+
# api = tweepy.Client(bearer_token=bearer_token, consumer_key=api_key,
|
60 |
+
# consumer_secret=secret_api_key, access_token=access_token,
|
61 |
+
# access_token_secret=secret_access_token,wait_on_rate_limit=True
|
62 |
+
# )
|
63 |
|
64 |
+
# #loops endlessly(60 sec interval) and checks,translates,and posts tweets
|
65 |
+
# # use this to get user id https://tweeterid.com/
|
66 |
+
# latest_tweet_id = 1605089422533218304 # change this if error or restart
|
67 |
+
# while True:
|
68 |
+
# # Get the first 20 tweets on the home timeline
|
69 |
+
# tweets = api.get_home_timeline(max_results=12,
|
70 |
+
# exclude='retweets',
|
71 |
+
# expansions="author_id", #since_id=latest_tweet_id
|
72 |
+
# start_time=last_minute)
|
73 |
+
# if tweets.data is not None:
|
74 |
+
# latest_tweet_id = tweets.meta['newest_id']
|
75 |
+
# for tweet in tweets.data:
|
76 |
+
# if tweet.author_id in users:
|
77 |
|
78 |
+
# print(f"Latest Tweet ID:{tweet.id}")
|
79 |
+
# print(f"Latest tweet: {tweet.text}")
|
80 |
|
81 |
+
# try:
|
82 |
+
# curr = tss.google(tweet.text, to_language='en', sleep_seconds=0.051)
|
83 |
+
# status = f"{curr[:254]}"
|
84 |
+
# api.create_tweet(text=status, quote_tweet_id=f"{tweet.id}")
|
85 |
+
# print(f"Tweet successfully sent: {status}")
|
86 |
+
# except:
|
87 |
+
# curr = tss.tencent(tweet.text, to_language='en', sleep_seconds=0.051)
|
88 |
+
# status = f"{curr[:254]}"
|
89 |
+
# api.create_tweet(text=status, quote_tweet_id=f"{tweet.id}")
|
90 |
+
# print(f"Tweet successfully sent: {status}")
|
91 |
+
# else:
|
92 |
+
# continue
|
93 |
+
# print(tweet.text)
|
94 |
+
# print("_______________________")
|
95 |
+
# time.sleep(60)
|
96 |
+
|
97 |
+
# translate(bearer_token,api_key,secret_api_key,access_token,secret_access_token)
|
98 |
|
99 |
|
100 |
|