Spell Thief (5e Feat)
From D&D Wiki
Prerequisites: the ability to cast at least one spell
Steeped in the arcane, you've spent years unraveling the mysteries of the weave, to the point that you can now steal the spells of others.
By watching a caster repeat a spell at least twice, you have the ability to attempt to steal said spell for yourself.
You may attempt to steal spells up to 5th level in this way, but you must have spell slots of the appropriate level for the stolen spell.
You must spend a certain amount of downtime experimenting for each level of the spell: 1 week for cantrips, 2 weeks for 1st level spells, 3 weeks for 2nd level spells, 1 month for 3rd level spells, 2 months for 4th level spells, and 5 months for 5th level spells.
If the spell is from the spell list of another class (meaning it does not also appear in your class's spell list), you must succeed on a DC 15 Intelligence (Arcana) check in order to understand the spell.
In addition, your spellcasting ability for spells stolen in this way is determined by the class list it appears in.