diff --git a/scripts/format.js b/scripts/format.js
index 5d6ddf66c..d89e6a48c 100644
--- a/scripts/format.js
+++ b/scripts/format.js
@@ -66,7 +66,7 @@ async function updatePlaylist(playlist) {
     const curr = i + 1
     updateTvgName(channel)
     updateTvgId(channel, playlist)
-    updateTvgCountry(channel, playlist)
+    updateTvgCountry(channel)
     normalizeUrl(channel)
 
     const data = channels[channel.tvg.id]
@@ -217,9 +217,9 @@ function updateTvgId(channel, playlist) {
   }
 }
 
-function updateTvgCountry(channel, playlist) {
-  const code = playlist.country.code
-  if (!channel.countries.length) {
+function updateTvgCountry(channel) {
+  if (!channel.countries.length && channel.tvg.id) {
+    const code = channel.tvg.id.split('.')[1] || null
     const name = utils.code2name(code)
     channel.countries = name ? [{ code, name }] : []
     channel.tvg.country = channel.countries.map(c => c.code.toUpperCase()).join(';')