Worth it to go to San Sebastian for the food?
YES - if you like food, then it might be a stretch. If you love food then go to San Sebastian or you will regret it. Flights to Bilbao airport are cheaper. Overnight train is long but take a sleeping pill and its really easy. Make sure to check out my recent report on my trip.
Last summer my husband and I spent a week in Barcelona and then flew up to San Sebastian for 4 days, largely to sample the cuisine. We thought it was well worth the trip, not only for the food but the city is lovely as well (although we were there in July so I can't speak for what it's like in January). We visited Akelarre, Martin Berasategui and a number of pinxtos bars and small places that were all excellent. We had looked into the train and discovered it was very slow so we found some flight deals on-line.
San Sebastian has terrific food, especially for pinxtos and traditional Basque cuisine. The area around the city has some of the best and most famous high end restaurants in Spain. There is more to than just food. It is an old resort town that still retains it's charm as well as a very lively Parte Vieja. Of course close by is the Guggenheim in Bilbao.
Is it worth a side trip depends on what you have plan for Barcelona. Besides the city itself, Catalonia is worth exploring and it also have some of the best high end restaurants. If I were to include San Sebastian, it would be for more than one or two days, otherwise, it is not worth the travel. I would fly into Bilbao for cheaper flights because the train is notoriously slow (almost a whole day each way).