ffbot 1.2.7__tar.gz → 1.2.9__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ffbot
3
- Version: 1.2.7
3
+ Version: 1.2.9
4
4
  Summary: Automate playing Yahoo Fantasy Football
5
5
  Home-page: https://github.com/amarvin/fantasy-football-bot
6
6
  Author: Alex Marvin
@@ -0,0 +1 @@
1
+ VERSION = "1.2.9"
@@ -128,8 +128,10 @@ def scrape(league, is_IDP: bool = False):
128
128
  df2 = pd.read_html(StringIO(html))[0]
129
129
  for _, row2 in df2.iterrows():
130
130
  week = "Week {}".format(row2["Week"])
131
- points = row2["Fan Pts"]
132
- if points[0] == "*":
131
+ points = row2.get("Fan Pts")
132
+ if points is None:
133
+ continue
134
+ elif points[0] == "*":
133
135
  # Game hasn't occured yet
134
136
  row[week] = float(points[1:])
135
137
  # row[week + ' projection'] = float(points[1:])
@@ -150,6 +152,9 @@ def scrape(league, is_IDP: bool = False):
150
152
  tqdm.pandas(desc="Scraping weekly forecasts")
151
153
  df = df.progress_apply(get_projections, axis=1)
152
154
 
155
+ # Remove players without projections
156
+ df = df[~pd.isna(df["Week 1"])]
157
+
153
158
  # Reorder columns
154
159
  columns = list(df.columns)
155
160
  columns[2], columns[1] = columns[1], columns[2]
@@ -185,13 +190,13 @@ def current_week():
185
190
 
186
191
  # Parse current week from a public league
187
192
  s = create_session()
188
- url = "https://football.fantasysports.yahoo.com/f1/{}".format(PUBLIC_LEAGUE)
193
+ url = "https://football.fantasysports.yahoo.com/f1/{}/1".format(PUBLIC_LEAGUE)
189
194
  s.headers["User-Agent"] = generate_user_agent()
190
195
  r = s.get(url)
191
196
  soup = bs(r.text, "lxml")
192
- matchups = soup.select_one("#matchupweek .matchups-body")
193
- weeks = re.findall(r"Week (\d+)", matchups.text)
194
- week = weeks[0]
197
+ REGEX_PATTERN = r"Week (\d+)"
198
+ m = re.search(REGEX_PATTERN, soup.text)
199
+ week = m.group(1)
195
200
  week = int(week)
196
201
 
197
202
  return week
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ffbot
3
- Version: 1.2.7
3
+ Version: 1.2.9
4
4
  Summary: Automate playing Yahoo Fantasy Football
5
5
  Home-page: https://github.com/amarvin/fantasy-football-bot
6
6
  Author: Alex Marvin
@@ -1 +0,0 @@
1
- VERSION = "1.2.7"
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes