o
    liu                     @   s(   d dl Z d dl T d	ddZd
ddZdS )    N)*frc                 C   s   t | d}d|d}d}tj|| dd|dj}t|}|d }t | i }|D ]/}|d	 }	|d
 dd }
|	ddd  }	|	d }	d|	v rKq*d|	v rPq*d|	v rUq*|	||
< q*|S )N Pvy9aaB4S6kDwkuU0aInJjae0UwWUu1Tapplication/jsonacceptZapiKeyzFhttps://prim.iledefrance-mobilites.fr/marketplace/v2/navitia/places?q=   FtimeoutverifyheadersZplacesidnamez (r   :,;.)printrequestsgettextjsonloadssplit)operatorstationcountrytokenheaderurldatasearch_listZ_sr   r    r#   XC:\Users\computer\Desktop\notes\tskylt4.0\server\20260117 - seems ok - no SNCB\france.py	pa_lookup   s*   




r%   pac                 C   s  |    } d}d|d}td|  d|  d }tj|dd|d	j}t|}g }|d
 d d d d }d}|D ]}	|	d }
|
d d dd }zt	j
d d | }W n    d| }tj|dd|d	j}t|}|t	j
d d |< Y z|d
 d d d }W n ty } z
t| W Y d }~nd }~ww zt|d d d d d d  }W n   dt|d d d d v rY q9d}Y z|d d d d d d d }W n ty } z
t| W Y d }~q9d }~ww z
|
d d d }W n'   z
|
d d d }W n ty } zt| W Y d }~Y q9d }~ww Y z|
d  d! }W n   Y q9d"|v r5d#}t|||| |d$|d d% |d&d'| d(g d)}|| q9t|ri|t	j
| | |  d*< |S d S )+Nr   r   r   zSTATION:zghttps://prim.iledefrance-mobilites.fr/marketplace/stop-monitoring?MonitoringRef=STIF%3AStopArea%3ASP%3Az%3Ar   Fr	   ZSiriZServiceDeliveryZStopMonitoringDeliveryr   ZMonitoredStopVisitZMonitoredVehicleJourneyZLineRefvaluez::   r   r&   zYhttps://prim.iledefrance-mobilites.fr/marketplace/requete-ligne?LineRef=STIF%3ALine%3A%3AZEstimatedTimetableDeliveryZEstimatedJourneyVersionFrameZEstimatedVehicleJourneyZVehicleMode	CANCELLEDUNKNOWNZPublishedLineNameZDestinationShortNameZDestinationNameZMonitoredCallZExpectedDepartureTimeRAILTRAIN0   -r   )r   transport_mode)destinationdirection_codeexpectedline
deviations
departures)lstriprstripr   r   r   r   r   r   r   v	operators	Exceptionstrupperreplaceappendlen)r   r   r   r   r   r    r!   resultsZstop_line_checkdepartures_dictr6   Z	stop_lineZdata2url2Z
stop_linese__typer4   r   when
new_recordr#   r#   r$   pa_load_departures   sx   



* &


rH   )r   )r   r&   )r9   r%   rH   r#   r#   r#   r$   <module>   s
   

I