You can use the Migration Assistant to copy user accounts and files (iTunes Library). Alternatively, you can just migrate the iTunes library manually. If your ditching the old iMac, be sure to deauthorize it in iTunes.
Then just setup the TV to connect to the new machine. The key here is you iTunes library needs to be copied to the new machine.