Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e93f0e6473 | ||
|
|
4fbdfef3ff | ||
|
|
38e031a9ba | ||
|
|
38b93884c2 | ||
|
|
862279c39c | ||
|
|
e9fdb3a04d | ||
|
|
363a985b16 | ||
|
|
5529bf1402 | ||
|
|
173fa33b8f | ||
|
|
bbe85db026 | ||
|
|
3437bb50a6 | ||
|
|
4cf720cc5d | ||
|
|
0e16e196b4 | ||
|
|
70616babbd | ||
|
|
3cd0ab79a8 | ||
|
|
3182d66e63 | ||
|
|
e60ff257e6 | ||
|
|
ef93c95f9d | ||
|
|
fb72c54ab7 | ||
|
|
a3915595e3 | ||
|
|
7cabd2e1b3 | ||
|
|
011deb41e0 | ||
|
|
0e67657698 | ||
|
|
bb05fc0b44 | ||
|
|
ee68221691 | ||
|
|
fcc0d8649b | ||
|
|
9695f0bc10 | ||
|
|
742ae622d2 | ||
|
|
973ef9d338 | ||
|
|
f8861b130d | ||
|
|
967d5aa16a | ||
|
|
08f2924c2a |
+190
-27
@@ -5,6 +5,7 @@ from urllib.parse import quote_plus
|
||||
from urllib.request import urlretrieve, urlopen, Request, HTTPError
|
||||
from threading import Thread
|
||||
from os import makedirs,path
|
||||
from functools import cache
|
||||
import json,sys,webbrowser,importlib,tomllib
|
||||
|
||||
def update():
|
||||
@@ -41,6 +42,10 @@ def dependency_setup():
|
||||
|
||||
print('dependencies ready')
|
||||
|
||||
def today():
|
||||
now=datetime.utcnow()
|
||||
return datetime(now.year,now.month,now.day)
|
||||
|
||||
# Astrology functions
|
||||
|
||||
def load_settings():
|
||||
@@ -51,6 +56,10 @@ def load_settings():
|
||||
return {
|
||||
'positions':'!positions',
|
||||
'transits':'!transits',
|
||||
'major_aspects':'!aspects major',
|
||||
'minor_aspects':'!aspects minor',
|
||||
'major_aspect_transits':'!aspects major transits',
|
||||
'minor_aspect_transits':'!aspects minor transits',
|
||||
}
|
||||
|
||||
def get_zodiac(angle):
|
||||
@@ -61,7 +70,8 @@ def get_zodiac(angle):
|
||||
def is_retrograde(speed):
|
||||
return speed<0
|
||||
|
||||
def get_positions_raw(date):
|
||||
@cache
|
||||
def get_positions_raw(date=today()):
|
||||
import swisseph as swe
|
||||
julian_day = swe.julday(date.year, date.month, date.day)
|
||||
planets = {
|
||||
@@ -94,7 +104,8 @@ def get_positions_raw(date):
|
||||
|
||||
return positions
|
||||
|
||||
def get_positions(date):
|
||||
@cache
|
||||
def get_positions(date=today()):
|
||||
positions={}
|
||||
|
||||
for name, position_raw in get_positions_raw(date).items():
|
||||
@@ -105,7 +116,7 @@ def get_positions(date):
|
||||
|
||||
return positions
|
||||
|
||||
def get_list_formatted(in_list,isare=True):
|
||||
def get_list_formatted(in_list,isare=False):
|
||||
match len(in_list):
|
||||
case 0:
|
||||
output='Nothing'
|
||||
@@ -125,7 +136,8 @@ def get_list_formatted(in_list,isare=True):
|
||||
output+=' are '
|
||||
return output
|
||||
|
||||
def get_positions_formatted(date):
|
||||
@cache
|
||||
def get_positions_formatted(date=today()):
|
||||
retrograde_planets=[]
|
||||
position_strings=[]
|
||||
|
||||
@@ -134,7 +146,7 @@ def get_positions_formatted(date):
|
||||
retrograde_planets.append(name)
|
||||
position_strings.append(name+' is in '+position['zodiac'])
|
||||
|
||||
positions_formatted=get_list_formatted(retrograde_planets)+'in Retrograde\n'
|
||||
positions_formatted=get_list_formatted(retrograde_planets,True)+'in Retrograde\n'
|
||||
|
||||
positions_formatted+=', '.join(position_strings[0:2])+'\n'
|
||||
positions_formatted+=', '.join(position_strings[2:5])+'\n'
|
||||
@@ -144,15 +156,16 @@ def get_positions_formatted(date):
|
||||
|
||||
return positions_formatted
|
||||
|
||||
def get_transits():
|
||||
seconds_in_1_day=86400
|
||||
now=datetime.utcnow()
|
||||
positions_now=get_positions(now)
|
||||
seconds_in_1_day=86400
|
||||
|
||||
@cache
|
||||
def get_transits(date=today(), maxdays=28):
|
||||
positions_now=get_positions(date)
|
||||
transits={}
|
||||
days=1
|
||||
|
||||
while len(transits)<12 and days<29:
|
||||
future_timestamp=now.timestamp()+(days*seconds_in_1_day)
|
||||
while len(transits)<12 and days<=maxdays:
|
||||
future_timestamp=date.timestamp()+(days*seconds_in_1_day)
|
||||
future_date=datetime.fromtimestamp(future_timestamp,timezone.utc)
|
||||
positions_future=get_positions(future_date)
|
||||
for name, position_future in positions_future.items():
|
||||
@@ -168,11 +181,13 @@ def get_transits():
|
||||
|
||||
return transits
|
||||
|
||||
def get_transits_formatted():
|
||||
date_format='%b %d'
|
||||
date_format='%b %d'
|
||||
|
||||
@cache
|
||||
def get_transits_formatted(date=today(), maxdays=28):
|
||||
transits_formatted=''
|
||||
|
||||
for name,transit in get_transits().items():
|
||||
for name,transit in get_transits(date, maxdays).items():
|
||||
if transit['zodiac']!=None:
|
||||
transits_formatted+=name+' is entering '+transit['zodiac']+' on '+transit['date'].strftime(date_format)+'\n'
|
||||
if transit['retrograde']==True:
|
||||
@@ -182,8 +197,9 @@ def get_transits_formatted():
|
||||
|
||||
return transits_formatted
|
||||
|
||||
def get_aspects(date, minor=False):
|
||||
positions=get_positions_raw(date)
|
||||
@cache
|
||||
def get_aspects(date=today(), minor=False):
|
||||
positions=get_positions_raw(date).copy()
|
||||
major_aspects={
|
||||
'conjuction':{'angle':0,'orb':10.0},
|
||||
'oposition':{'angle':180,'orb':10.0},
|
||||
@@ -225,18 +241,151 @@ def get_aspects(date, minor=False):
|
||||
|
||||
return aspects
|
||||
|
||||
def get_aspects_formatted(date,minor=False):
|
||||
@cache
|
||||
def get_aspects_formatted(date=today(),minor=False):
|
||||
aspects_formatted=''
|
||||
|
||||
for planet,aspects in get_aspects(date,minor).items():
|
||||
aspects_formatted+=planet+' is in '
|
||||
aspects_list=[]
|
||||
for aspect_name,aspect_planets in aspects.items():
|
||||
aspects_list.append(aspect_name+' with '+get_list_formatted(aspect_planets,False))
|
||||
aspects_formatted+=get_list_formatted(aspects_list,False)+'\n'
|
||||
aspects_list.append(aspect_name+' with '+get_list_formatted(aspect_planets))
|
||||
aspects_formatted+=get_list_formatted(aspects_list)+'\n'
|
||||
|
||||
return aspects_formatted
|
||||
|
||||
@cache
|
||||
def get_aspect_transits(date=today(),minor=False,maxdays=28):
|
||||
date_now=today()
|
||||
timestamp_now=date_now.timestamp()
|
||||
aspects_now=get_aspects(date_now,minor)
|
||||
pre_transits={}
|
||||
days=0
|
||||
|
||||
def aspects_contains(aspects,planet_a,aspect=None,planet_b=None):
|
||||
if planet_a not in aspects:
|
||||
return False
|
||||
elif aspect and aspect not in aspects[planet_a]:
|
||||
return False
|
||||
elif aspect and planet_b and planet_b not in aspects[planet_a][aspect]:
|
||||
return False
|
||||
return True
|
||||
|
||||
def ensure_pre_path(planet_a,aspect=None):
|
||||
if planet_a not in pre_transits:
|
||||
pre_transits[planet_a]={}
|
||||
if aspect and aspect not in pre_transits[planet_a]:
|
||||
pre_transits[planet_a][aspect]={}
|
||||
|
||||
def pre_planet_b(planet_a,aspect,planet_b,date_future,direction):
|
||||
ensure_pre_path(planet_a,aspect)
|
||||
pre_transits[planet_a][aspect][planet_b]={
|
||||
'date':date_future,
|
||||
'direction':direction
|
||||
}
|
||||
|
||||
def pre_aspect(planet_a,aspect,planets,date_future,direction):
|
||||
ensure_pre_path(planet_a)
|
||||
pre_transits[planet_a][aspect]={}
|
||||
for planet_b in planets:
|
||||
pre_planet_b(planet_a,aspect,planet_b,date_future,direction)
|
||||
|
||||
def pre_planet_a(planet_a,aspects,date_future,direction):
|
||||
pre_transits[planet_a]={}
|
||||
for aspect,planets in aspects.items():
|
||||
pre_aspect(planet_a,aspect,planets,date_future,direction)
|
||||
|
||||
while days<maxdays:
|
||||
days+=1
|
||||
timestamp_future=timestamp_now+(seconds_in_1_day*days)
|
||||
date_future=datetime.fromtimestamp(timestamp_future,timezone.utc)
|
||||
aspects_future=get_aspects(date_future)
|
||||
for planet_a,aspects in aspects_now.items():
|
||||
try:
|
||||
pre_transits[planet_a]
|
||||
except KeyError:
|
||||
if not aspects_contains(aspects_future,planet_a):
|
||||
pre_planet_a(planet_a,aspects,date_future,'exiting')
|
||||
continue
|
||||
for aspect, planets in aspects.items():
|
||||
try:
|
||||
pre_transits[planet_a][aspect]
|
||||
except KeyError:
|
||||
if not aspects_contains(aspects_future,planet_a,aspect):
|
||||
pre_aspect(planet_a,aspect,planets,date_future,'exiting')
|
||||
continue
|
||||
for planet_b in planets:
|
||||
try:
|
||||
pre_transits[planet_a][aspect][planet_b]
|
||||
except KeyError:
|
||||
if not aspects_contains(aspects_future,planet_a,aspect,planet_b):
|
||||
pre_planet_b(planet_a,aspect,planet_b,date_future,'exiting')
|
||||
|
||||
days=0
|
||||
while days<maxdays:
|
||||
days+=1
|
||||
timestamp_future=timestamp_now+(seconds_in_1_day*days)
|
||||
date_future=datetime.fromtimestamp(timestamp_future,timezone.utc)
|
||||
aspects_future=get_aspects(date_future)
|
||||
for planet_a,aspects in aspects_future.items():
|
||||
try:
|
||||
pre_transits[planet_a]
|
||||
except KeyError:
|
||||
if not aspects_contains(aspects_now,planet_a):
|
||||
pre_planet_a(planet_a,aspects,date_future,'entering')
|
||||
continue
|
||||
for aspect, planets in aspects.items():
|
||||
try:
|
||||
pre_transits[planet_a][aspect]
|
||||
except KeyError:
|
||||
if not aspects_contains(aspects_now,planet_a,aspect):
|
||||
pre_aspect(planet_a,aspect,planets,date_future,'entering')
|
||||
continue
|
||||
for planet_b in planets:
|
||||
try:
|
||||
pre_transits[planet_a][aspect][planet_b]
|
||||
except KeyError:
|
||||
if not aspects_contains(aspects_now,planet_a,aspect,planet_b):
|
||||
pre_planet_b(planet_a,aspect,planet_b,date_future,'entering')
|
||||
|
||||
post_transits={}
|
||||
|
||||
for planet_a,aspects in pre_transits.items():
|
||||
post_transits[planet_a]={}
|
||||
for aspect,planets in aspects.items():
|
||||
for planet_b,transit in planets.items():
|
||||
direction=transit['direction']
|
||||
date=transit['date']
|
||||
if direction not in post_transits[planet_a]:
|
||||
post_transits[planet_a][direction]={}
|
||||
if date not in post_transits[planet_a][direction]:
|
||||
post_transits[planet_a][direction][date]={}
|
||||
if aspect not in post_transits[planet_a][direction][date]:
|
||||
post_transits[planet_a][direction][date][aspect]=[]
|
||||
post_transits[planet_a][direction][date][aspect].append(planet_b)
|
||||
|
||||
return post_transits
|
||||
|
||||
@cache
|
||||
def get_aspect_transits_formatted(date=today(),minor=False,maxdays=28):
|
||||
aspect_transits=get_aspect_transits(date,minor,maxdays)
|
||||
aspect_transits_formatted=''
|
||||
|
||||
for planet_a,directions in aspect_transits.items():
|
||||
aspect_transits_formatted+=planet_a+' is '
|
||||
direction_list=[]
|
||||
for direction,dates in directions.items():
|
||||
date_list=[]
|
||||
for date,aspects in dates.items():
|
||||
aspect_list=[]
|
||||
for aspect,planets in aspects.items():
|
||||
aspect_list.append(aspect+' with '+get_list_formatted(planets))
|
||||
date_list.append(get_list_formatted(aspect_list)+' on '+date.strftime(date_format))
|
||||
direction_list.append(direction+' '+get_list_formatted(date_list))
|
||||
aspect_transits_formatted+=get_list_formatted(direction_list)+'\n'
|
||||
|
||||
return aspect_transits_formatted
|
||||
|
||||
# Twitch functions
|
||||
|
||||
device_code=None
|
||||
@@ -334,7 +483,7 @@ def main():
|
||||
async def on_chat_message(data: eventsub.chat.MessageEvent):
|
||||
config=load_settings()
|
||||
if data['message']['text']==config['positions']:
|
||||
for line in get_positions_formatted(datetime.now()).splitlines(False):
|
||||
for line in get_positions_formatted().splitlines(False):
|
||||
await client.channel.chat.send_message(line,data['message_id'])
|
||||
return
|
||||
if data['message']['text']==config['transits']:
|
||||
@@ -342,11 +491,19 @@ def main():
|
||||
await client.channel.chat.send_message(line,data['message_id'])
|
||||
return
|
||||
if data['message']['text']==config['major_aspects']:
|
||||
for line in get_aspects_formatted(datetime.now()).splitlines(False):
|
||||
for line in get_aspects_formatted().splitlines(False):
|
||||
await client.channel.chat.send_message(line,data['message_id'])
|
||||
return
|
||||
if data['message']['text']==config['minor_aspects']:
|
||||
for line in get_aspects_formatted(datetime.now(),True).splitlines(False):
|
||||
for line in get_aspects_formatted(minor=True).splitlines(False):
|
||||
await client.channel.chat.send_message(line,data['message_id'])
|
||||
return
|
||||
if data['message']['text']==config['major_aspect_transits']:
|
||||
for line in get_aspect_transits_formatted().splitlines(False):
|
||||
await client.channel.chat.send_message(line,data['message_id'])
|
||||
return
|
||||
if data['message']['text']==config['minor_aspect_transits']:
|
||||
for line in get_aspect_transits_formatted(minor=True).splitlines(False):
|
||||
await client.channel.chat.send_message(line,data['message_id'])
|
||||
return
|
||||
|
||||
@@ -403,6 +560,8 @@ def script_properties():
|
||||
obspython.obs_properties_add_text(properties,'transits','transits',obspython.OBS_TEXT_DEFAULT)
|
||||
obspython.obs_properties_add_text(properties,'major_aspects','major aspects',obspython.OBS_TEXT_DEFAULT)
|
||||
obspython.obs_properties_add_text(properties,'minor_aspects','minor aspects',obspython.OBS_TEXT_DEFAULT)
|
||||
obspython.obs_properties_add_text(properties,'major_aspect_transits','major aspect transits',obspython.OBS_TEXT_DEFAULT)
|
||||
obspython.obs_properties_add_text(properties,'minor_aspect_transits','minor aspect transits',obspython.OBS_TEXT_DEFAULT)
|
||||
return properties
|
||||
|
||||
def script_defaults(settings):
|
||||
@@ -412,6 +571,8 @@ def script_defaults(settings):
|
||||
obspython.obs_data_set_default_string(settings,'transits','!transits')
|
||||
obspython.obs_data_set_default_string(settings,'major_aspects','!aspects major')
|
||||
obspython.obs_data_set_default_string(settings,'minor_aspects','!aspects minor')
|
||||
obspython.obs_data_set_default_string(settings,'major_aspect_transits','!aspects major transits')
|
||||
obspython.obs_data_set_default_string(settings,'minor_aspect_transits','!aspects minor transits')
|
||||
|
||||
def script_load(settings):
|
||||
global obs_settings, save_tokens, load_tokens, load_settings
|
||||
@@ -442,8 +603,10 @@ if __name__ == '__main__':
|
||||
def script_path():
|
||||
return path.dirname(__file__)+'/'
|
||||
dependency_setup()
|
||||
#print(get_positions_formatted(datetime(2025,7,21)))
|
||||
#print(get_transits_formatted())
|
||||
#main()
|
||||
print(get_aspects_formatted(datetime(2025,7,21)))
|
||||
print(get_aspects_formatted(datetime(2025,7,21),True))
|
||||
print(get_positions_formatted())
|
||||
print(get_transits_formatted())
|
||||
print(get_aspects_formatted())
|
||||
print(get_aspects_formatted(minor=True))
|
||||
print(get_aspect_transits_formatted())
|
||||
print(get_aspect_transits_formatted(minor=True))
|
||||
main()
|
||||
Reference in New Issue
Block a user