I deleted system/library/frameworks and now my Mac will not boot up

So I was watching a video on YouTube on how to take out adware off of my Mac and so i didn’t see that I deleted system/library/frameworks/. So then I go and test to see if safari has any more pop ups and all is good but then I wanted to switch to my faster WiFi and when I clicked the WiFi picture then it just disappeared and I didn’t know what happened so I just hard reset my Mac. Now I cant get in to the login screen all it does is turn on and loads half way then turns off so I go into safe mode and try and reinstall my mac os no not letting me do that. So I don’t have time travel so I’m stuck. I know one thing and that is that when I delete frameworks I left it in trash and in safe mode I have access to terminal. Can somebody help me out please. I have a 2009 Mac running on high Sierra.
Using "macos put back trash command line" a search reveals discussions like the one below.
https://discussions.apple.com/thread/7831626

The Apple Support article, "How to reinstall macOS" is below as it has some options you may want to try if you've not already had a chance.
https://support.apple.com/en-us/HT204904

Original thread: https://forums.imore.com/threads/i-deleted-system-library-frameworks-and-now-my-mac-will-not-boot-up.398506/