Add url tag to output
This commit is contained in:
		
							parent
							
								
									287bb4f71b
								
							
						
					
					
						commit
						d49333a9a9
					
				| 
						 | 
					@ -110,8 +110,8 @@ utils.escapeString = function (string, defaultValue = '') {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
utils.convertToXMLTV = function ({ config, channels, programs }) {
 | 
					utils.convertToXMLTV = function ({ config, channels, programs }) {
 | 
				
			||||||
 | 
					  const url = config.site ? 'https://' + config.site : null
 | 
				
			||||||
  let output = `<?xml version="1.0" encoding="UTF-8" ?><tv>\r\n`
 | 
					  let output = `<?xml version="1.0" encoding="UTF-8" ?><tv>\r\n`
 | 
				
			||||||
 | 
					 | 
				
			||||||
  for (let channel of channels) {
 | 
					  for (let channel of channels) {
 | 
				
			||||||
    const id = this.escapeString(channel['xmltv_id'])
 | 
					    const id = this.escapeString(channel['xmltv_id'])
 | 
				
			||||||
    const displayName = this.escapeString(channel.name)
 | 
					    const displayName = this.escapeString(channel.name)
 | 
				
			||||||
| 
						 | 
					@ -120,6 +120,9 @@ utils.convertToXMLTV = function ({ config, channels, programs }) {
 | 
				
			||||||
      const logo = this.escapeString(channel.logo)
 | 
					      const logo = this.escapeString(channel.logo)
 | 
				
			||||||
      output += `<icon src="${logo}"/>`
 | 
					      output += `<icon src="${logo}"/>`
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					    if (url) {
 | 
				
			||||||
 | 
					      output += `<url>${url}</url>`
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
    output += `</channel>\r\n`
 | 
					    output += `</channel>\r\n`
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -61,9 +61,10 @@ it('can convert object to xmltv string', () => {
 | 
				
			||||||
      lang: 'it'
 | 
					      lang: 'it'
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  ]
 | 
					  ]
 | 
				
			||||||
  const output = utils.convertToXMLTV({ channels, programs })
 | 
					  const config = { site: 'example.com' }
 | 
				
			||||||
 | 
					  const output = utils.convertToXMLTV({ config, channels, programs })
 | 
				
			||||||
  expect(output).toBe(
 | 
					  expect(output).toBe(
 | 
				
			||||||
    '<?xml version="1.0" encoding="UTF-8" ?><tv>\r\n<channel id="1TV.com"><display-name>1 TV</display-name><icon src="https://example.com/logos/1TV.png"/></channel>\r\n<channel id="2TV.com"><display-name>2 TV</display-name></channel>\r\n<programme start="20210319060000 +0000" stop="20210319063000 +0000" channel="1TV.com"><title lang="it">Program 1</title><desc lang="it">Description for Program 1</desc><category lang="it">Test</category><icon src="https://example.com/images/Program1.png?x=шеллы&sid=777"/></programme>\r\n</tv>'
 | 
					    '<?xml version="1.0" encoding="UTF-8" ?><tv>\r\n<channel id="1TV.com"><display-name>1 TV</display-name><icon src="https://example.com/logos/1TV.png"/><url>https://example.com</url></channel>\r\n<channel id="2TV.com"><display-name>2 TV</display-name><url>https://example.com</url></channel>\r\n<programme start="20210319060000 +0000" stop="20210319063000 +0000" channel="1TV.com"><title lang="it">Program 1</title><desc lang="it">Description for Program 1</desc><category lang="it">Test</category><icon src="https://example.com/images/Program1.png?x=шеллы&sid=777"/></programme>\r\n</tv>'
 | 
				
			||||||
  )
 | 
					  )
 | 
				
			||||||
})
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue