
    Y/h                     l    S SK r S SKrS SKrS rS rS rS rSS jrS rS r	S	 r
\S
:X  a  \
" 5         gg)    Nc                      [         R                  " S5      n U R                  S:w  a!  [        S[	        U R                  5      -   5      eU R
                  n[        R                  " U5      nU$ )z9Retrieve the fpl player data from the hard-coded url
    z7https://fantasy.premierleague.com/api/bootstrap-static/   Response was code )requestsgetstatus_code	Exceptionstrtextjsonloads)responseresponseStrdatas      ?g:\Projects\Python Projects\fpl_model\scripts\utills\getters.pyget_datar      sY     ||UVHs",s83G3G/HHII--K::k"DK    c                 V   SnU[        U 5      -   S-   nSnUS:X  a   [        R                  " U5      nUS:X  a  M  UR
                  S:w  a!  [        S[        UR
                  5      -   5      e[        R                  " UR                  5      nU$ !   [        R                  " S5         Nu= f)zvRetrieve the player-specific detailed data

Args:
    player_id (int): ID of the player whose data is to be retrieved
z6https://fantasy.premierleague.com/api/element-summary//    r   r   
r
   r   r   timesleepr   r	   r   r   r   )	player_idbase_urlfull_urlr   r   s        r   get_individual_player_datar      s     HH#i.(3.HH
b.	||H-H b.
 s",s83G3G/HHII::hmm$DK	JJqM   B B(c                 V   SnU[        U 5      -   S-   nSnUS:X  a   [        R                  " U5      nUS:X  a  M  UR
                  S:w  a!  [        S[        UR
                  5      -   5      e[        R                  " UR                  5      nU$ !   [        R                  " S5         Nu= f)Retrieve the summary/history data for a specific entry/team

Args:
    entry_id (int) : ID of the team whose data is to be retrieved
,https://fantasy.premierleague.com/api/entry/z	/history/r   r   r   r   r   entry_idr   r   r   r   s        r   get_entry_datar%   "   s     >H#h-'+5HH
b.	||H-H b.
 s",s83G3G/HHII::hmm$DK	JJqMr   c                 V   SnU[        U 5      -   S-   nSnUS:X  a   [        R                  " U5      nUS:X  a  M  UR
                  S:w  a!  [        S[        UR
                  5      -   5      e[        R                  " UR                  5      nU$ !   [        R                  " S5         Nu= f)r!   r"   r   r   r   r   r   r   r#   s        r   get_entry_personal_datar'   5   s     >H#h-'#-HH
b.	||H-H b.
 s",s83G3G/HHII::hmm$DK	JJqMr   c                    Sn/ n[        X!S-   5       H  nU[        U 5      -   S-   [        U5      -   S-   nSnUS:X  a   [        R                  " U5      nUS:X  a  M  UR                  S:w  a!  [        S[        UR                  5      -   5      e[        R                  " UR                  5      nXH/-  nM     U$ !   [        R
                  " S5         N~= f)	z~Retrieve the gw-by-gw data for a specific entry/team

Args:
    entry_id (int) : ID of the team whose data is to be retrieved
r"      z/event/z/picks/r   r   r   r   )ranger
   r   r   r   r   r   r	   r   r   r   )	r$   num_gwsstart_gwr   gw_datair   r   r   s	            r   get_entry_gws_datar/   H   s     >HG8QY'c(m+i7#a&@9L"n#<<1 "n
 3&03x7K7K3LLMMzz(--(6 ( N

1s   B99Cc                 V   SnU[        U 5      -   S-   nSnUS:X  a   [        R                  " U5      nUS:X  a  M  UR
                  S:w  a!  [        S[        UR
                  5      -   5      e[        R                  " UR                  5      nU$ !   [        R                  " S5         Nu= f)z~Retrieve the transfer data for a specific entry/team

Args:
    entry_id (int) : ID of the team whose data is to be retrieved
r"   z/transfers/r   r   r   r   r   r#   s        r   get_entry_transfers_datar1   ^   s     >H#h-'-7HH
b.	||H-H b.
 s",s83G3G/HHII::hmm$DK	JJqMr   c                  4   Sn SnUS:X  a   [         R                  " U 5      nUS:X  a  M  UR                  S:w  a!  [        S[        UR                  5      -   5      e[        R                  " UR                  5      nU$ !   [        R                  " S5         Nu= f)z.Retrieve the fixtures data for the season
    z/https://fantasy.premierleague.com/api/fixtures/r   r   r   r   )
r   r   r   r   r   r	   r
   r   r   r   )urlr   r   s      r   get_fixtures_datar4   q   s     <CH
b.	||C(H b.
 s",s83G3G/HHII::hmm$DK	JJqMs   A= =Bc                      [        5       n [        SS5       n[        R                  " X5        S S S 5        g ! , (       d  f       g = f)Nzraw.jsonw)r   openr   dump)r   outfs     r   mainr:      s-    :D	j#	$		$ 
		s	   7
A__main__)r)   )r   r   r   r   r   r%   r'   r/   r1   r4   r:   __name__ r   r   <module>r>      sJ      &&&,&
 zF r   