Jump to content

Request: Fangraphs (MLB) workflow


Recommended Posts

5 hours ago, giovanni said:

@JBigs welcome to the forum! I can help with the migration, but the website has changed in the meantime. For example, the URL syntax suggested earlier (more than 10 years ago!) in the thread (http://www.fangraphs.com/quickplayersearch.aspx?name={query}) no longer works. Do you know how to search for a player via URL? 

Thank you! Yes the website has undergone quite a bit of change over the years!

 

I think I do! They no longer use the simple ulr+{query}. As happens, someone I know actually just created a Shortcut that does exactly what I am looking to replicate in Alfred, so hopefully that can help. I will try my best but I don't fully understand what is happening, just enough to get me frustrated!

 

Using the Shortcut script, it looks like for search they're using a .json POST and it returns the information for the players matching the query. Is this helpful? I have been messing around trying to figure out how to create this request but honestly my 10 year old comp sci class in college only got me so far!

 

image.thumb.png.851bc3cba1096babc9f0bcef235399c6.png

Link to comment
5 minutes ago, giovanni said:

yes this is using their API which they probably developed over the last decade. I also see there is a python package to fetch the data. What would you like to accomplish? To see a list of players in Alfred, select one and get their stats on the fangraphs website? 

Yes exactly! I was hoping to get suggestions of players in Alfred as I type then be able to select one and go to the main stats page on fangraphs. Is that possible?

Link to comment
3 minutes ago, giovanni said:

@JBigs something like this

Exactly what I was looking for! Thank you!

 

I would love to learn how to do this myself. Do you have any suggestions on resources to learn how to create custom workflows that use python scripts?

Link to comment
2 hours ago, JBigs said:

Exactly what I was looking for! Thank you!

Glad it's helpful! Please thank your friend who provided the API URL and key. I had not realized Shortcuts could be so sophisticated ... almost like an ugly Alfred!

 

2 hours ago, JBigs said:

I would love to learn how to do this myself. Do you have any suggestions on resources

I am in no way an expert, but as a fellow amateur programmer, I can share what works for me:

  1. Set a goal (a workflow that does something you need, or a feature you want to add to an existing workflow) – you will be more motivated to overcome difficulties. For example: you might want to show some particular statistics underneath the player's name in the Fangraphs workflow. 
  2. Take apart workflows that do related things, from great creators like @vitor, @zeitlings, @pseudometa, @Mr Pennyworth, @deanishe, etc. or anything in the Gallery: change small and big things, break them, fix them etc. 
  3. If you are stuck:
    1. ask chatGPT or similar to explain your own code back to you: you will be surprised by what you learn 😉
    2. ask here! this is a great, welcoming community
    3. ask other forums, but provide details and reproducible code
  4. Once you have something that works for you, share your code on Github. Why? People will find bugs, give you ideas for improvements, or even contribute to your code. Or, random users might use one of your workflows, and then – with a 'thank you' – give you that little puff of dopamine we all need to carry on 😅

Good luck! I will post this Fangraphs workflow on Github at some point and I will be honored to receive your first pull request!

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...