BraydenMoore commited on
Commit
3506785
·
verified ·
1 Parent(s): 029b9e5

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +27 -36
main.py CHANGED
@@ -103,57 +103,48 @@ def proxy(url):
103
  @app.route('/')
104
  def index():
105
  id = request.args.get('id')
106
- if 'current_feed' in session and request.args.get('new', 'false') == 'false':
107
- feed = session['current_feed']
108
- url = live_urls[int(feed)]
109
- else:
110
  feed = random.randint(0, len(live_urls) - 1)
111
- url = live_urls[int(feed)]
112
- session['current_feed'] = feed
113
-
114
- if id:
115
- url = live_urls[int(id)]
116
- feed = id
117
- session['current_feed'] = id
118
 
119
- url = encode_url(url)
120
- url = url.replace('640x480','1280x960').replace('COUNTER','')
 
 
 
121
 
122
- id = feed
123
  ip = ''.join(url.split('//')[-1]).split(':')[0]
124
  info = get_location(ip)
125
  country = info['country'].lower()
126
  name = (info['city'] + ", " + info['region']).lower()
127
  page_title = (info['city'] + ", " + info['region'] + ", " + country).lower()
128
  timezone = pytz.timezone(info['timezone'])
129
- time = dt.datetime.now(timezone)
130
- time = time.strftime("%I:%M:%S %p")
131
  loc = info['loc']
132
  X, Y = latlon_to_pixel(info['loc'])
133
  proxy_url = 'proxy/' + url
134
- logging.info(f"Generated proxy URL: {proxy_url}")
135
  loc_link = f"https://www.google.com/maps/search/{loc}"
136
  ip_link = url
137
- try:
138
- owner = owner_dict[ip]
139
- except:
140
- owner = 'unknown'
141
  return render_template('index.html',
142
- name=name,
143
- url=encode_url(proxy_url),
144
- info=info,
145
- country=country,
146
- time=time,
147
- timezone=timezone,
148
- ip=ip,
149
- ip_link=ip_link,
150
- loc=loc,
151
- loc_link=loc_link,
152
- owner=owner,
153
- X=X,
154
- Y=Y,
155
- id=id,
156
- page_title=page_title)
 
157
 
158
 
159
  if __name__ == '__main__':
 
103
  @app.route('/')
104
  def index():
105
  id = request.args.get('id')
106
+
107
+ if id is None:
 
 
108
  feed = random.randint(0, len(live_urls) - 1)
109
+ return redirect(f"/?id={feed}")
 
 
 
 
 
 
110
 
111
+ id = int(id)
112
+ url = live_urls[id]
113
+ session['current_feed'] = id
114
+
115
+ url = encode_url(url).replace('640x480','1280x960').replace('COUNTER','')
116
 
 
117
  ip = ''.join(url.split('//')[-1]).split(':')[0]
118
  info = get_location(ip)
119
  country = info['country'].lower()
120
  name = (info['city'] + ", " + info['region']).lower()
121
  page_title = (info['city'] + ", " + info['region'] + ", " + country).lower()
122
  timezone = pytz.timezone(info['timezone'])
123
+ time = dt.datetime.now(timezone).strftime("%I:%M:%S %p")
 
124
  loc = info['loc']
125
  X, Y = latlon_to_pixel(info['loc'])
126
  proxy_url = 'proxy/' + url
 
127
  loc_link = f"https://www.google.com/maps/search/{loc}"
128
  ip_link = url
129
+ owner = owner_dict.get(ip, 'unknown')
130
+
 
 
131
  return render_template('index.html',
132
+ name=name,
133
+ url=encode_url(proxy_url),
134
+ info=info,
135
+ country=country,
136
+ time=time,
137
+ timezone=timezone,
138
+ ip=ip,
139
+ ip_link=ip_link,
140
+ loc=loc,
141
+ loc_link=loc_link,
142
+ owner=owner,
143
+ X=X,
144
+ Y=Y,
145
+ id=id,
146
+ page_title=page_title
147
+ )
148
 
149
 
150
  if __name__ == '__main__':