Dynamo cutting out after a couple of seconds
You could try measuring the voltage the dynamo outputs when spinning the wheel. Strip two thin wires on both ends , insert them into the dynamo plug (plug which is usually present on the hub to which the wire going to the light Is attached), attach a multimeter and spin the wheel. If the voltage drops to zero/drops considerably after a few seconds whilst still spinning the wheel the problem is not with the dynamo and it's probably a short circuit/ground or bad electrical connection somewhere.

Example of what a dynamo plug/ connector might look like:
https://i.stack.imgur.com/fQyr8.png