Skip to content

Commit

Permalink
small web ui change before new tag
Browse files Browse the repository at this point in the history
  • Loading branch information
justin025 committed Dec 13, 2024
1 parent a5673d6 commit c7c9a31
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/onthespot/parse_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
DEEZER_URL_REGEX = re.compile(r'https://www.deezer.com/(?:[a-z]{2}/)?(?P<type>album|playlist|track|artist)/(?P<id>\d+)')
SOUNDCLOUD_URL_REGEX = re.compile(r"https://soundcloud.com/[-\w:/]+")
SPOTIFY_URL_REGEX = re.compile(r"https://open.spotify.com/(intl-([a-zA-Z]+)/|)(?P<type>track|album|artist|playlist|episode|show)/(?P<id>[0-9a-zA-Z]{22})(\?si=.+?)?$")
TIDAL_URL_REGEX = re.compile( r"https://listen.tidal.com/(?P<type>album|track|artist|playlist)/(?P<id>[a-z0-9-\-]+)" )
TIDAL_URL_REGEX = re.compile( r"https://(www\.|listen\.)?.tidal.com/(?P<type>album|track|artist|playlist)/(?P<id>[a-z0-9-\-]+)" )
YOUTUBE_URL_REGEX = re.compile(r"https://(www\.|music\.)?youtube\.com/watch\?v=(?P<video_id>[a-zA-Z0-9_-]+)(&list=(?P<list_id>[a-zA-Z0-9_-]+))?")
#QOBUZ_INTERPRETER_URL_REGEX = re.compile(r"https?://www\.qobuz\.com/\w\w-\w\w/interpreter/[-\w]+/([-\w]+)")

Expand Down
19 changes: 18 additions & 1 deletion src/onthespot/templates/search.html
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@

const serviceIcon = item.item_service ? `<img src="/icons/${item.item_service}.png" style="width: 20px; height: 20px; margin-right: 5px;">` : '';

const copyButton = `
<button class="download-action-button" onclick="copyToClipboard('${item.item_url}')">
<img src="icons/link.png" alt="Copy">
</button>
`;

const downloadButton = `
<button class="download-action-button" onclick="handleDownload('${item.item_url}')">
<img src="icons/download.png" alt="Download">
Expand Down Expand Up @@ -85,7 +91,7 @@
row.appendChild(cell4);

const cell5 = document.createElement('td');
cell5.innerHTML = downloadButton;
cell5.innerHTML = `${copyButton}${downloadButton}`;
row.appendChild(cell5);

tableBody.appendChild(row);
Expand All @@ -98,6 +104,17 @@
return string.charAt(0).toUpperCase() + string.slice(1);
}

function copyToClipboard(text) {
navigator.clipboard.writeText(text)
.then(() => {
console.log('Link copied to clipboard');
// alert('Link copied to clipboard!');
})
.catch(err => {
console.error('Failed to copy: ', err);
});
}

function handleDownload(url) {
fetch(`/download/${encodeURIComponent(url)}`, {
method: 'POST',
Expand Down

0 comments on commit c7c9a31

Please sign in to comment.